4

My single-spa contains 4 react applications. Each has its own react-router-dom. If I hit browser refresh from one of the 4 applications it says page not found. Application is deployed in the apache server in Linux OS.

I don't know whether I'm missing any configuration in the base application. It works fine in the development server which is webpack and node.

pageNotfoUnd
  • 666
  • 10
  • 20
satheesh
  • 403
  • 5
  • 15
  • 1
    Have a look at this answer and the related question: https://stackoverflow.com/a/40591955/7867822 – Anurag Srivastava Jan 01 '21 at 14:25
  • Thank you very much. Your suggestion helped me to solve this problem. If anybody wants help with the ".htaccess" file use this link https://docs.bolt.cm/4.0/howto/making-sure-htaccess-works – satheesh Jan 02 '21 at 04:05

1 Answers1

4

Yes, because your deployed application is not aware of the routes. In single page applications, only your / route exists. All routes in SPAs are client side routes and don't make seperate GET request to the server.

I faced the same issue when deploying my application to netlify. It showed default netlify 404 page. Then I added _redirects file to public directory with following contents:

/* /index.html 200

This redirected all 404 routes to default index.html and thus used the client side routing. You need to find something similar for your deployed version.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Shubham Shinde
  • 136
  • 1
  • 1
  • 8
  • 1
    Thanks, @Shubham Shinde. If anybody wants help with the ".htaccess" file use this link https://docs.bolt.cm/4.0/howto/making-sure-htaccess-works – satheesh Jan 02 '21 at 04:07