问题
Vue项目部署后,请求返回 “We’re sorry but XXX doesn’t work properly without JavaScript enabled. Please enable it to
continue.<”
控制台报错: Uncaught SyntaxError: Unexpected token ‘<’


原因
查看 Nginx 的错误日志
2024/05/11 17:11:42 [error] 40792#19592: *1 CreateFile() “D:\nginx-1.19.6/html/favicon.ico” failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: “GET /favicon.ico HTTP/1.1”, host: “localhost”, referrer: “http://localhost/”
提示找不到项目文件,应该是 Nginx 的代理配置问题,最终发现是 root 路径的斜杠配置错误,windows 环境。
location /abc/def/ {
root D:/xxx-front; # "/" 斜杠配置错误
index index.html;
try_files $uri $uri/ /index.html =404;
......
}
解决
修改 location 中的 root: D:/xxx 改为 D:\xxx
location /abc/def/ {
root D:\xxx-front; # "/" 改为 "\"
index index.html;
try_files $uri $uri/ /index.html =404;
......
}

2万+

被折叠的 条评论
为什么被折叠?



