Redirects not working with react app and functions

The point is to redirect all requests to single function. It’s my _redirects file contents:
/api/* /.netlify/functions/sau 200

on localhost it works. Such requests as /api/whatever1 or /api/whatever2 are redirected to /api/sau, but on productions such requests return 404 error. I noticed that only when I requests /api/sau it returns correct response.

@rromikas If /api/ exists on your production site, then you must force the redirect with the exclamation mark (!) in your redirect instruction.

/api/* /.netlify/functions/sau 200!

I added exclamation mark, but it still doesn’t work.
This is the code repository: GitHub - rromikas/ntl-deploy-template

I don’t use functions, so I may be way off base here, but your redirect points to /.netlify/functions/sau while your actual function seems to be at /functions/sau. Have you tried defining your redirect to point to what appears to me to be the actual location of the function?

/.netlify/functions/sau is correct redirection route. Functions are being built into that folder. It can’t be wrong.

When I remove react app from repository, redirects work., but I need react app on the same url as functions.

Hey there, @rromikas. Can you respond to this thread with your Netlify site name as well as your most recent build log?

Hi, I resolved this issue. I put _redirects file with my inside public folder of react app. In this way redirections rules are visible and works with react app. Previously, I used redirection rules inside netlify.toml file that was placed in root folder. This way some rules were ignored or didn’t work as expected.

1 Like

Hey there, @rromikas

Thank you so much for letting us know! I am so glad to hear you found a solution for this :netliconfetti: We always appreciate when folks share their solutions, as this will be helpful for future Forums members who encounter something similar.

1 Like