404 on refresh with Vue Router
Hi, I've recently joined railway and love the ease of getting my project live! I have one small issue. My application is a Vue2 SPA using vue-router in history mode. The project builds and deploys fine. Whenever I refresh a page that isn't the home page i get a 404 error as nginx is not redirecting back to index. I need to change the nginx.conf files to something like this - https://stackoverflow.com/questions/52471007/how-to-handle-404-error-request-in-vuejs-spa-with-nginx-server
Is it possible to supply/edit the nginx.conf file pre build? ID 7bf323ec-abda-4aaa-834b-3521cc4043f9
Stack Overflow
How to handle 404 error request in vuejs SPA with nginx server
I have set up my vue-cli version 3 SPA so that any requests not found in my routes.js file will default to my 404 view as shown in the official documentation:
Inserted near bottom of routes.js fil...
7 Replies
Hello, did you solve this? i have the same error
Unfortunately not so I moved the project to firebase
The static file nixpack provider with a custom build comand solves this.
You can also use a generic nginx container
Or vercel is a good option for frontends
I see yep, was hoping to avoid these added complexities for such a simple change. thanks for the info @Finn
ye, try nixpacks then ig
you need a Staticfile containing path to your dist dir
then add and env var
NIXPACKS_BUILD_CMD
to your build command. then you should be golden @yolobrolothanks will try later
your very welcome 👍