CSS file blocked: MIME type mismatch (X-Content-Type-Options: nosniff)

后端 未结 9 2120
失恋的感觉
失恋的感觉 2020-12-08 13:21

I am developing an Angular 4 app and I want to apply some global styles. Following the tutorial at the angular site, I\'ve created a \"styles.css\" file in the root directo

9条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-08 13:57

    Some answers suggested removing rel="stylesheet", that didn't work out for me however. According to the expressjs documentation: https://expressjs.com/en/starter/static-files.html use express.static function to serve static files such as CSS, JavaScript,etc...

    app.use(express.static('public'))
    

    and from there you should be able to load any file under the public directory for example, if you have a style.css file inside the directory {PROJECT_PATH}/public/css/

    http://localhost:3000/css/style.css will work.

提交回复
热议问题