简体   繁体   English

拒绝应用样式,因为它的 MIME 类型('text/html')不是受支持的样式表类型

[英]Refused to apply style because its MIME type ('text/html') is not a supported stylesheet type

I am getting multiple errors when trying to access my application:尝试访问我的应用程序时出现多个错误:

Refused to apply style from 'http://localhost:8000/styles.2466d75470f9c2227ee1.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
Refused to execute script from 'http://localhost:8000/runtime.205c879ce8dbb57b9cca.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
Refused to execute script from 'http://localhost:8000/polyfills.ce2bae2f7a5e6e1939c2.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
Refused to execute script from 'http://localhost:8000/main.510119795446e9da8a78.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

Folder structure:文件夹结构:

- main project folder
- - src
- - - config
- - - - express file
- - client
- - - build
- - - - index.html and other files after build

In express file I have this:在快递文件中我有这个:

app.use(express.static('../../client/build/'));
app.get('*', (req, res) => {
    res.sendFile(path.resolve(__dirname, '../../client', 'build', 'index.html'));
});

What am I doing wrong?我究竟做错了什么?

Problem was with app.use(express.static('../../client/build/'));问题出在app.use(express.static('../../client/build/'));

It should be app.use(express.static(path.join(__dirname, '..', '..', 'client', 'build')));它应该是app.use(express.static(path.join(__dirname, '..', '..', 'client', 'build')));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 拒绝应用{filename}中的样式,因为它的MIME类型(&#39;text / html&#39;)不是受支持的样式表MIME类型 - Refused to apply style from {filename} because its MIME type ('text/html') is not a supported stylesheet MIME type Django:拒绝从...应用样式,因为它的 MIME 类型(&#39;text/html&#39;)不是受支持的样式表 MIME 类型 - Django: Refused to apply style from ... because its MIME type ('text/html') is not a supported stylesheet MIME type 拒绝应用样式,因为它的 MIME 类型 ('text/html') 不是受支持的样式表 MIME 类型 - Refused to apply style because its MIME type ('text/html') is not a supported stylesheet MIME type 拒绝应用“ <URL> &#39;,因为它的MIME类型(&#39;text / html&#39;)不是受支持的样式表MIME类型,并且启用了严格的MIME检查 - Refused to apply style from '<URL>' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled 拒绝应用来自“xxx/style.css”的样式,因为它的 MIME 类型(“text/html”)不是受支持的样式表 MIME 类型 - Refused to apply style from 'xxx/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type 拒绝应用来自 'http://localhost:3000/css/style.css' 的样式,因为它的 MIME 类型 ('text/html') 不是受支持的样式表 MIME 类型 - Refused to apply style from 'http://localhost:3000/css/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type 应用 css 样式时出现角度错误:拒绝从“路径”应用样式,因为其 MIME 类型(“文本/html”)不是受支持的样式表 MIME 类型 - Angular error when applying css style: Refused to apply style from 'path' because its MIME type ('text/html') is not a supported stylesheet MIME type 拒绝应用来自 'http://localhost:3000/assets/styles/signup.css' 的样式,因为它的 MIME 类型('text/html')不是受支持的样式表 MIME 类型 - Refused to apply style from 'http://localhost:3000/assets/styles/signup.css' because its MIME type('text/html')is not a supported stylesheet MIME type 拒绝从...应用样式,因为它的 MIME 类型 (&#39;text/html&#39;) 不是受支持的样式表 MIME 类型,并且启用了严格的 MIME 检查 - Refused to apply style from... because its MIME type ('text/html') is not a supported style-sheet MIME type, and strict MIME checking is enabled Chrome的控制台错误:拒绝应用样式,因为其MIME类型(&#39;text / html&#39;) - The console of Chrome error : Refused to apply style because its MIME type ('text/html')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM