SPA redirect is breaking netlify functions

Hello,

Has something changed with redirects and functions?

I have a SPA with a global rule in the _redirects.

# SPA Redirect
/* /index.html 200

This used to be able to still access the Netlify functions endpoint /.netlify/functions/hello-world

However, today is seems when accessing the endpoints they were showing index.html.

Had to resolve the issue by creating a custom path in the redirects file for functions:

# custom path for functions
/nf-functions/* /.netlify/functions/:splat 200

# SPA Redirect
/* /index.html 200
5 Likes

We are also seeing the same issue. None of our functions (across several apps) are currently working correctly. I would really appreciate an update from Netlify on this. It seems to me that this is a huge deal if it affects other users in the same way it has affected us today.

We have the same phenomenon. Live system was down for hours because of this. Thanks to @BenSuperscript for the temporary fix idea, our application is now running. Of course we are waiting for netlify’s response.

Hello,

Thanks so much for reporting this. I have notified our team and we are looking into this further. If you could share your site name that would be very helpful so that we could look into each case.

Best,
Hillary

We also implemented the good idea of @BenSuperscript to make this work again. Still need to apply it to a few more apps, but I thought I would share how it can be done in netlify.toml, in case it’s useful for anyone else:

[[redirects]]
  from = "/nf-functions/*"
  to = "/.netlify/functions/:splat"
  status = 200
  
[[redirects]]
  from = "/*"
  to = "/index.html"
  status = 200

And then you need to do call the functions by using /nf-functions/* instead of /.netlify/functions/*.

1 Like

Hi there folks! Thanks so much for reaching out. As an update, we have identified the error and the appropriate team is working on this now. I will follow up as soon as we have more information.

Thanks to everyone who has shared some interim solutions :netlisparkles:

3 Likes

We have rolled back the change that caused this. Your redirects and functions should now be working as expected again. You might need to redeploy in order for the fix to work, so please do try that.

If you test this and are still seeing errors let us know!

2 Likes

I have a problem. I deployed a function but when I’m trying to access it, it still redirects to index.html.
I’m using the URL from the backoffice.

Note: It’s working perfectly locally

Thanks

It appears to be working fine, @moshfeu. Has this been resolved?

OMG just spent hours on this. In my case the function redirect has to come BEFORE the "./* redirect for the SPA. Very frustrating. Please update the docs. Thanks!