vue 打包到 nginx Uncaught SyntaxError: Unexpected token <
因为是history报此错误
官方配置history的解决方案:
location / {
try_files $uri $uri/ /index.html;
}
其他方案:
location / {
# 不缓存html,防止程序更新后缓存继续生效
if ($request_filename ~* .*\.(?:htm|html)$) {
add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
access_log on;
}
root html/web;
index index.html index.htm;
try_files $uri $uri/ @router;
}
location @router{
rewrite ^.+(?<!js|css|png|map)$ /web/index.html break;
}