Netlify _redirects not working (CORs error on Apple OS only)

I’m calling an external API from the frontend that grabs player images.

export const getPlayerPortrait = (playerId) => {
  return fetch(`https://cms.nhl.bamgrid.com/images/headshots/current/60x60/${playerId}@2x.jpg`)
    .then((response) => {
      return {
        url: response.url,
        id: playerId,
      };
    });
};

This works perfectly fine on local and production for Windows and Android devices. However, on Apple OS devices, I get a CORs error (Allow-Access-Control).

The images load intitially on Apple devices, however when reloading the page they do not render again. If I clear browsing cache and reload the page then they will show up until I reload once more.

I’ve done tons of research and found out about redirects from Netlify. So I set that up and did this:

fetch(`/api/images/headshots/current/60x60/${playerId}@2x.jpg`)

_redirects file

/api/* https://cms.nhl.bamgrid.com/:splat 200

/* /index.html  200

This doesn’t seem to fix anything, and it also breaks the call from working on local and production for Android and Windows devices.

You can access the live website here: https://livefeed.netlify.app

To reproduce, use an Apple device (iPhone or Macbook) and go to the link above. Select a date that has games (ex. May 12, 2023). You will notice the images load intitially, but if you reload the page they will not render again.

Check the network calls that look something like this:

image

If you clear the browser cache and reload the page, the images will show up again until you reload once more.

Ignore any other bugs the site may have. It’s a side project and a work in progress :slight_smile:

Cheers!

hi there, before we dig in, did you see this brand new guide on debugging redirects?

I strongly suggest you give it a thorough read through and see if this fixes your problem:

if not, please post again, and we’ll try and troubleshoot.

1 Like

FYI I have resolved the issue. Had nothing to do with _redirect. Was mainly my own error but also Safari caches API calls and didn’t mine for whatever reason.

oh awesome! glad you were able to self solve. (: