Docker部署Vue.js页面刷新出现Nginx 404错误求助
Vue项目Docker部署后刷新子路由出现404问题
已参考Stack Overflow上关于「Vue.js搭配Nginx使用」的提问并尝试解决方案,但问题仍未解决。
问题现象
- Docker镜像构建完成后,访问
localhost:8080可正常显示,页面刷新无异常 - 导航至
localhost:8080/add_app时首次加载正常,但刷新该页面会出现404错误
- Docker Desktop中的错误信息:

Dockerfile配置
# build stage FROM node:lts-alpine as build-stage WORKDIR /app COPY ./platform-frontend/package*.json ./ RUN npm install COPY ./platform-frontend . RUN npm run build # production stage FROM nginx:stable-alpine as production-stage COPY --from=build-stage /app/dist /usr/share/nginx/html COPY --from=build-stage /app/nginx/nginx.conf /etc/nginx/conf.d/nginx.conf EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]
Nginx配置文件(nginx.conf)
server { listen 80; server_name localhost; location / { root /app/dist; index index.html index.html; try_files $uri /index.html; } }
项目结构

内容的提问来源于stack exchange,提问作者senadk
相关产品推荐
相关产品推荐

