0

Let's say I have a /test route for my SPA and I also have a folder named test in the public folder of the project. What happens if I go to my-website.com/test? Which page, if any, would I get?

Thank you for your help.

JacopoStanchi
  • 1,962
  • 5
  • 33
  • 61
  • 1
    Depends on your server setup / the server side framework you're using. Usually your SPA will be served by a catchall route on the server side which means that all paths unless specified will route through to the SPA and routing will handled on the client side instead using React Router. – adaam Apr 30 '19 at 18:03
  • But the setup is always the same for React, it's a Node.js server. So what would happen if I create something like I said without changing anything to the server config? – JacopoStanchi May 01 '19 at 09:05
  • 1
    You usually need to explicitly setup serving of static assets from the public folder in any server side framework. Express for example: `app.use(express.static('public'))`. So look for something like that in your source code. The order of routes in express or any other framework matters so if your catchall route is defined before the serving of static assets then the SPA will be served first. Hope that makes sense. This answer explains it well: https://stackoverflow.com/questions/26349497/node-express-with-static-html-how-to-route-all-requests-to-index-html – adaam May 02 '19 at 12:08

0 Answers0