-
Notifications
You must be signed in to change notification settings - Fork 0
Troubleshooting
Damiano Fossa edited this page Jul 8, 2022
·
2 revisions
React uses client-side routers (CSR), and with it there are no longer requests to the server every time the routes changes. Instead, the CSR handles that locally on the browser. That means, if there is no specific configuration in the server, accessing exact pages leads to 404 Not Found error.
To fix this issue, follow these simple steps:
If you are using Apache, add the following lines to the .htaccess file:
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
Or, if you are using Nginx, add the following lines to the .conf file:
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.html break;
}
}