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.

3
  • 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. Commented Apr 30, 2019 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? Commented May 1, 2019 at 9: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: stackoverflow.com/questions/26349497/… Commented May 2, 2019 at 12:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.