错误信息
_app.config.js:1 Uncaught SyntaxError: Unexpected token '<'
daas/assets/index.edf40865.js:1 Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
原因
.env.production(生产环境配置文件)
# 基础路径
VITE_PUBLIC_PATH = /demo
vite.config.ts
export default ({
mode }: ConfigEnv): UserConfig => {
// 获取 .env 环境配置文件
const env = loadEnv(mode, process.cwd());
return {
// 基础路径
base: env.VITE_BASE_PATH,
...
}
}
nginx 配置
upstream 3.com {
server 127.0.0.1:81;
}
server {
listen 3000;
server_name 3.com;
# 监听demo路径
location /demo {
#指向资源的路径,alias为当前index.html的目录,在处理二级路由时,应当使用alias,而不是使用root
alias /opt/d/demo;
index index.html;
# /demo/index.html; 这里需要添加 /demo,而不能直接写/index.html;
try_files $uri $uri/ /demo/index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
还没有评论,来说两句吧...