my static files are not loading for 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..
<script src="/js/order.js"></script>
Try this:
app.use(express.static(path.join(__dirname, 'src/public')));