Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ashiqsultan opened this issue May 5, 2021 · 3 comments · May be fixed by #2909
Open

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

ashiqsultan opened this issue May 5, 2021 · 3 comments · May be fixed by #2909

Comments

@ashiqsultan
Copy link

ashiqsultan commented May 5, 2021

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

@chrisvdp
Copy link

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 added a commit to chrisvdp/vuejs.org that referenced this issue Nov 22, 2021
@maximkrouk
Copy link

maximkrouk commented Feb 18, 2022

+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

@SenadK95
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants