[英]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.