Browser refresh shows "page not found" error, when the single-spa application is deployed in the subdirectory

Viewed 1733

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.

1 Answers

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.

Related