[英]static files are not loading for ejs (Node.js)
my static files are not loading for ejs.我的 static 文件没有为 ejs 加载。 I get following error.
我收到以下错误。 I have tried in several ways to get loaded the statics but still I'm getting following errors
我已经尝试了几种方法来加载静力学,但我仍然遇到以下错误
Refused to apply style from 'http://localhost:8080/css/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
info-order:63 GET http://localhost:8080/js/order.js net::ERR_ABORTED 404 (Not Found)
info-order:1 Refused to apply style from 'http://localhost:8080/css/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
my config file has following code..我的配置文件有以下代码..
const express = require("express");
const path = require("path");
/*config view engine*/
let configViewEngine = (app) => {
app.use(express.static(path.join(__dirname + "./src/public")));
app.set("viewEngine", "ejs");
app.set("views", "./src/views");
};
module.exports = configViewEngine;
And I have link the stylesheet as follow.我已经链接样式表如下。
<link rel="stylesheet" href="/css/style.css" />
my script tag on ejs as foillow..我在 ejs 上的脚本标记为 foillow..
<script src="/js/order.js"></script>
Try this:尝试这个:
app.use(express.static(path.join(__dirname, 'src/public')));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.