To fix React-router URLs don’t work when refreshing or writing manually, we should fix our server config.
For instance, we write
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
</IfModule>
in the .htaccess file if we’re using Apache.
The file redirects all requests to index.html of the React app so that React Router can be used to render the routes instead of the server.