【发布时间】:2019-06-24 10:57:36
【问题描述】:
我有一个由 Nuxtjs 构建的站点,在 nginx proxy_pass 后面运行。
假设 Nuxtjs 站点位于 http://10.001.002.003/,主站点是 http://example.com。这是 example.com 的 nginx 配置
location /main-page/ {
proxy_pass http://10.001.002.003/; #this is the Nuxt site
}
location /api/ {
rewrite /api/(.*) /$1 break;
proxy_pass https://api.example.com/;
}
location / {
root /home/www/html/example/dist;
try_files $uri $uri/ /index.html;
#index index.html;
}
我在http://10.001.002.003/_nuxt/script1.js 有一个脚本,而该脚本又可以从http://example.com/main-page/_nuxt/script1.js 访问
问题来了,如果我浏览到http://example.com/main-page,脚本不会执行。但是,如果我浏览到http://10.001.002.003,它就可以工作。
这是html
<head>
<link rel="preload" href="http://example.com/main-page/_nuxt/script1.js" as="script">
</head>
<body>
<script src="http://example.com/main-page/_nuxt/script1.js" defer></script>
</body>
【问题讨论】:
-
控制台有错误吗?您可以验证在网络选项卡中下载的脚本吗?
-
控制台没有错误。是的,脚本已下载。
-
只有其他想法... mime 类型怎么样?我认为如果控制台出错,那么控制台中会出现错误。
-
同样的问题!您是否在 example.com 上使用 Cloudflare?
标签: javascript html nginx nuxt.js