当我将页面404重定向到我的登录页面时出错,它没有css,也不接受Node.js中的html



我使用这些重定向页面404到我的页面登录:

router.get("/login", (req, res) =>{ res.render("auth/master"); });
router.get("*", (req, res) => { res.redirect("/login"); });
router.get("/", (req, res) => { res.render("main/layout/home"); })

它已经运行,但我的主页和登录页面不接受html和控制台通知:

Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:3001/login".
login:1 Uncaught SyntaxError: Unexpected token '<'

如果您的网页HTML代码可能包含对样式表的URL引用。该样式表URL可能不正确,或者您尚未创建样式表。

您在浏览器控制台中收到的错误消息

资源被解释为样式表,但使用MIME类型text/html/传输:"http://localhost:3001/login".

当样式表URL不正确时发生。服务器会向您的浏览器发送一个错误页面(可能是404页面(,其中包含解释错误的内容。浏览器对自己说,"等等,这应该是一个样式表,但事实并非如此",并显示此控制台消息。

View Source ...通常是解决此类问题的好方法。

最新更新