v2.vuejs.org icon indicating copy to clipboard operation
v2.vuejs.org copied to clipboard

Dockerize Vue.js App | Example docker file with Nginx causes 404 issues

Open ashiqsultan opened this issue 4 years ago • 3 comments
trafficstars

The Example provided in the page "Dockerize Vue.js App" with Nginx, causes 404 issues for the deployed app. I think we need to add a custom nginx conf file. link: https://vuejs.org/v2/cookbook/dockerize-vuejs-app.html#Real-World-Example

The Nginx 404 is displayed only when directly accessing a route other than '/' So its displayed only when directly accessing the example.com/articles from the browser URL but works fine when going to example.com

ashiqsultan avatar May 05 '21 11:05 ashiqsultan

I ran into this as well. The example seems to be missing some nginx config to try index.html

https://stackoverflow.com/questions/47655869/how-to-use-vue-js-with-nginx

chrisvdp avatar Nov 22 '21 21:11 chrisvdp

+1 for @chrisvdp's comment, adding try_files $uri $uri/ /index.html; to default.conf fixes the issue.

I added nginx folder with a default.conf file to my project and copying it to my container using Dockerfile.

Here is my Dockerfile (I'm using Vue3 Vitesse template btw, so Dockerfile uses pnpm to build the project)

.txt extensions are added to files just to upload them to GitHub, remove it after downloading

maximkrouk avatar Feb 18 '22 11:02 maximkrouk

@maximkrouk Thank you!!!! Your conf and dockerfile fixed it for me.

SenadK95 avatar Dec 13 '22 13:12 SenadK95