【发布时间】:2020-01-27 16:09:40
【问题描述】:
我正在从一个 vue 应用程序(使用 create-vue-app 创建)提供一个 dist 文件夹。但是,当我不指向某些特定路线时,它会很好地发挥作用,只需使用根路线而无需任何东西。但是,如果我指定子路由,例如 '/static' ,它不会为 vue app dist index.html 提供服务...我在浏览器中收到消息:
Refused to apply style from 'http://localhost:3000/css/app.fc1b515e.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
4localhost/:1 GET http://localhost:3000/js/app.6869d12b.js net::ERR_ABORTED 404 (Not Found)
但是,如果我将 favicon.ico 输入到浏览器的路径中,它会找到它...
有时,我还会收到错误消息,告诉我 javascript 未启用(这是错误的)...
这就是我设置路线的方式:
app.use('/static',express.static(path.join(__dirname, '\\client\\dist')));
【问题讨论】:
-
你在使用 vue-router 吗?
标签: node.js express vue.js routing static