Hi Netlify team. I came across one problem after deployment. Problem is proxy not working after deploying my React app in netlify. I am using api deployed in heroku. My heroku api is https://domain.herokuapp.com.
So i am fetching my api like
const fetch= await axios.get(/api/users)
I have put __redirect file in public folder as
Netlify processes redirect rules from top to bottom. So, any rule that matches first is applied and the rest of the file is ignored. In your case, /* matches routes under /api/* too. Thus the problem. If you switch the order of the rules, it should work.
You can’t apply multiple redirects to the same file.
So take this example:
Suppose you want 2 redirects on your website. You wish to redirect /foo/bar.png to https://www.netlify.com/ and you also need to add the SPA redirect. According to your current configuration, you’ve done this:
Notice that, /foo/bar.png matches in both cases, case 1: /* = all files in the website and case 2: /foo/bar.png = only the bar.png image. So when someone requests /foo/bar.png, the redirect engine checks for the redirect rules and finds a match /*. It applies the redirect and ignores the rest of the redirect file. So even though you have the correct redirect setup in the next line, it won’t work because the first rule matched the requested file.
What would happen is, when someone requests /foo/bar.png, the redirect engine checks for redirect rules and find a match. It redirects to https://www.netlify.com/ and stops processing after that. So your redirect works fine.
Thus, it’s always recommended that add more-specific rules to the top and the wildcard rules to the end. So your file should look like: