I have a built using create-react-app and hosted in Netlify. I created a file called _redirects
in folder 'public', but it did not work. The redirect is not happening.
/* /index.html 200
I tried change the package.json:
"scripts": {
....
"build": "react-scripts build && echo '/* /index.html 200' | cat >build/_redirects ",
...
}
I tried create a file /netlify.toml on the root (same level as package.json)
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
force = false
I read this stackoverflow question and I tried everything: Catch all redirect for create-react-app in netlify
I think the problem is in the way I am deploying it (because nothing is working) and I tested it in another application that I created a branch for deploy and the file _redirects
worked perfectly.
Way I'm deploying on netlify - Image
Page: https://apuro-branch-main.netlify.app/
I'm testing the following direct link: https://apuro-branch-main.netlify.app/login
I tested putting in new branch and all files in the root folder (instead of inside a folder) and it worked.
I think that (/* /index.html 200)
doesn't work if the deploy is not performed in the root directory (in my case, I did it inside a folder called apuro-frontend/).
So, I've already discovered that all my difficulty is related to the deployment inside a folder (apuro-frontend/). Although I understand the problem now, I still couldn't find a solution for this specific case.