I served a react page under 127.0.0.1/react/
sub directary with my gateway. It can be viewed by explorer with 127.0.0.1/react/
. But if I input 127.0.0.1/react
it returns my vue page served under 127.0.0.1
which failed to match any routes.
There is another example https://www.curseforge.com/minecraft/mc-mods.
https://www.curseforge.com/minecraft/mc-mods
is okay while https://www.curseforge.com/minecraft/mc-mods/
returns 404 not found
. What's the difference?
Ordinary users might treat them as same url, they would expect both of them can access the page. So how should I make them both accessable?
Asked
Active
Viewed 65 times
1

lotsof one
- 77
- 5
-
1What's your gateway? Nginx? It'll all come down to the configuration... Nginx AND ReactJS. i.e. How do you handle the trailing slash? e.g. - https://stackoverflow.com/questions/41216330/trailing-forward-slash-in-react-router-routes – Nick Grealy May 18 '20 at 03:57
1 Answers
1
The server can return whatever it wants for any path, and doesn't need to follow any particular standard conventions. However, most servers do follow some norms:
/react/
usually ends up fetching the index file (usuallyindex.html
unless configured otherwise) from thereact
folder under the web root. This is returned to the client transparent... the client isn't redirected./react
This is a request for a file namedreact
under the main root. However, in the absence of such file, and the presence of a folder, it's common to redirect the client to/react/
.
How you do this depends entirely on your server configuration. You didn't tell us the server, so we can't point you in the right direction.

Brad
- 159,648
- 54
- 349
- 530
-
Oh yeah. I forgot to configure to redirect `/react` to `/react/`. configure a redirect and place it after `/react/` proxypass and it works. Also adding a same proxypass of `/react` works. It should also work for nginx. – lotsof one May 18 '20 at 05:33