【问题标题】:css stylesheet not applied when it is deployed in heroku.but works in localhost node.js [closed]css 样式表在部署在 heroku.js 中时未应用,但在 localhost node.js 中有效 [关闭]
【发布时间】:2020-11-30 10:47:42
【问题描述】:

const express = require('express');
const nodemailer = require('nodemailer');


const app = express();
const path = require('path');

const PORT = 5000;

app.use(express.json());
app.use(express.urlencoded({
    extended: false
}));


//app.use(express.static(path.join(__dirname, '/public')));
app.use(express.static('public'));
<link rel="stylesheet" href="stylesheets/main.css" type="text/css" />

enter image description here

拒绝应用来自 'https://selvamlicagent.herokuapp.com/stylesheets/main.css' 的样式,因为它的 MIME 类型 ('text/html') 不是受支持的样式表 MIME 类型,并且启用了严格的 MIME 检查.

【问题讨论】:

    标签: css node.js heroku stylesheet


    【解决方案1】:

    当您将public(小写p)传递给express.static() 时,您的公用文件夹名为“Public”。重命名您的文件夹以与代码完全匹配,然后重试。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-07
      • 1970-01-01
      • 1970-01-01
      • 2020-06-17
      • 2013-10-22
      • 1970-01-01
      • 2012-09-27
      • 2012-11-12
      相关资源
      最近更新 更多