I’ve been trying for a while now to setup my current react website and backend with Netlify.
I was able to setup the lambda functions and they are currently working if I use for example
/.netlify/functions/server/latest_netflix
However, the current website and mobile app currently use /api/latest_netflix for that, so I’ve been trying to setup that redirect in my netlify.toml file, but for some reason I just can’t seem to get it working
[[redirects]]
from = “/api/*”
to = ‘/.netlify/functions/servers/:splat’
status = 200
query = {path = “:path”} # apply this rule for /old-path?path=example`
this is how I setup this api endpoint in servers.js
Hi, @ntoporcov. I’m seeing this in the most recent deploy details:
No redirect rules processed
So, I think the redirects are not working because the netlify.toml file isn’t found. I also don’t see log lines similar to this for that deploy:
11:03:30 PM: Found Netlify configuration file netlify.toml in site root
11:03:30 PM: Found Netlify configuration file(s). Overriding site configuration
Would you please confirm that netlify.toml is part of this Git repo and that it is located in the base directory of the repo?
I was trying to set it up on a different branch and since then I made updates to the master branch which resulted in auto deploys here. I turned that off since then.
The latest one for my Deploy Preview had that line
Hi, @ntoporcov, I spot checked a few deploys and I’m looking at either the wrong deploys or the wrong site.
Would you please send me a link to that deploy?
If so, I’d be happy to see what the redirect defined is and if it is working or not. If it isn’t working, I’ll find out why and offer suggestions to (hopefully) get it working as required (or file an issue if the root cause is a “bug”).
@luke@fool I’m facing a similar issue. How can I fix this ? What should be the route in express (should they prepend with .netlify/functions/server) ? And what should be the redirect rule if I’ve to rewrite all requests to my express app ?
My repository is this.
Hey,
Thanks for the response.
Okay, yeah so the redirect started working when I made few changes in the express code, i.e I changed app.use('/', router) to app.get('/', handler).
Hi, @rajkumaar23, thank you for both letting us know you found a solution and for sharing some details about that solution. This will hopefully help others searching this site in the future.