MIME类型('text / html')不是受支持的样式表MIME类型,并且启用了严格的MIME检查

我在Heroku上的Angular 8应用程序中遇到了Deploy问题。错误:

Refused to apply style from 'https://capitu.herokuapp.com/styles.3ff695c00d717f2d2a11.css' because its MIME type ('text/html') is not a supported stylesheet MIME type,and strict MIME checking is enabled.

GET https://capitu.herokuapp.com/runtime-es2015.edb2fcf2778e7bf1d426.js net::ERR_ABORTED 404 (Not Found)

也可以在控制台上的链接上看到它: https://capitu.herokuapp.com/

我的文件package.json具有此配置

{
  "name": "chat-bot","version": "0.0.0","scripts": {
    "ng": "ng","start": "node server.js","build": "ng build","test": "ng test","lint": "ng lint","e2e": "ng e2e","postinstall": "./node_modules/.bin/ng build --prod","build:prod": "ng build --prod","heroku-postbuild": "npm run build:prod"
  },"engines": {
    "node": "v10.16.3","npm": "5.8.0"
  },"private": true,"dependencies": {
    "@angular/animations": "~8.2.7","@angular/common": "~8.2.7","@angular/compiler": "~8.2.7","@angular/core": "~8.2.7","@angular/forms": "~8.2.7","@angular/platform-browser": "~8.2.7","@angular/platform-browser-dynamic": "~8.2.7","@angular/router": "~8.2.7","express": "^4.17.1","path": "^0.12.7","rxjs": "~6.4.0","tslib": "^1.10.0","zone.js": "~0.9.1"
  },"devDependencies": {
    "@angular-devkit/build-angular": "~0.803.5","@angular/cli": "~8.3.5","@angular/compiler-cli": "~8.2.7","@angular/language-service": "~8.2.7","@types/jasmine": "~3.3.8","@types/jasminewd2": "~2.0.3","@types/node": "~8.9.4","api-ai-javascript": "^2.0.0-beta.21","codelyzer": "^5.0.0","jasmine-core": "~3.4.0","jasmine-spec-reporter": "~4.2.1","karma": "~4.1.0","karma-chrome-launcher": "~2.2.0","karma-coverage-istanbul-reporter": "~2.0.1","karma-jasmine": "~2.0.1","karma-jasmine-html-reporter": "^1.4.0","protractor": "~5.4.0","ts-node": "~7.0.0","tslint": "~5.15.0","typescript": "~3.5.3"
  }
}

我的Node.js服务器具有配置:

//Install express server
const express = require('express');
const path = require('path');

const app = express();

// Serve only the static files form the angularapp directory
app.use(express.static(__dirname + '/src'));

app.get('/',(req,res) => {

res.render(__dirname + '/index.html')
});

// Start the app by listening on the default Heroku port
app.listen(process.env.PORT || 8080);

有人会解决这个问题吗?感激

omegaxjy 回答:MIME类型('text / html')不是受支持的样式表MIME类型,并且启用了严格的MIME检查

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3117524.html

大家都在问