0

i have a problem with my vue js project after running npm run build && cd /dist then http-server -p 3000 when accessing localhost:3000/ all the files comes as 404 not found , when i remove the publicPath (/app/) and retry it all files comes as 200 but nothing appears on screen (which is normal) but after trying to access any router i get the custom 404 file that i created in the project which is wired at first i thought it may be an ngnix issue but if the ngnix server is not finding build file how come the 404 file get served i tried for days now but i can't seem to find the issue the final goal is to deploy the project on cloudflare pages and the only way i found to reproduce it locally is through npm run build then http-server -p 3000 here is my ngnix file

`worker_processes 4;

events { worker_connections 1024; }

http { include mime.types;

server { listen 8080;

root /usr/share/nginx/html;
index index.html;

error_page 404 /404.html;
location = /404.html {
  internal;
}

location /myapp/ {
  alias /usr/share/nginx/html/;
  try_files $uri $uri/ /index.html;
}
location / {
  alias /usr/share/nginx/html/;
  try_files $uri $uri/ /index.html;
}

} } and here is the vue.config.jsconst { defineConfig } = require('@vue/cli-service') module.exports = defineConfig({ transpileDependencies: true, devServer:{ allowedHosts:"all" }, publicPath:"/myapp/" }) `

please note that no erros are showing, and running serve -s after npm run build or docker-compose up --build the project runs perfectly any help is appreciated, thanks

a working vue js project after npm run build and http-server -p 3000

Mohamed Amine
  • 33
  • 1
  • 6
  • Nor sure what's wrong with your project - but feel free to replicate our fully working vue frontend - it has Dockerfile, nginx config and everything - https://github.com/relizaio/rebom/tree/master/frontend – taleodor Apr 30 '23 at 01:07

0 Answers0