Facing an issue with Next.js static exported files and with browser router-enabled React app

When I load the URL with routing, it's throwing an error. Generally, in Vercel/Nginx, we have a configuration to solve this, and in Nginx, we add the following line to achieve it: try_files $uri $uri.html /$uri /index.html; I tried using Traefik middleware for the same. I attempted several configurations, but they didn’t work. I also tried adding the above line to the nginx.conf file in the respective Docker container, and it worked properly. However, the problem is that each time we redeploy, this configuration is removed. Any ideas on how to handle this dynamically?
No description
7 Replies
Siumauricio
Siumauricio7mo ago
why don't you mount the file in the container using the volumes?
Siumauricio
Siumauricio7mo ago
you can do something like this
No description
Siumauricio
Siumauricio7mo ago
and that file will be persistent between any deployments
ksanjeeb
ksanjeebOP7mo ago
This is what I've tried for workaround but no luck
No description
Siumauricio
Siumauricio7mo ago
try to do ./nginx.conf and /etc/nginx/nginx.conf
ksanjeeb
ksanjeebOP7mo ago
Hey it worked just changed some thing in this try_files $uri $uri.html /$uri /index.html; Okay you are saying to modify the main file 👍 I will try that as well. Just a thought—what if we add an option to view and directly modify the Nginx configuration? I believe CapRover already offering that functionality.👀
Siumauricio
Siumauricio7mo ago
yeah the thing is we don't offer native nginx since we use traefik instead of nginx

Did you find this page helpful?