0
我想能夠發送不同的路徑,如/ stuff和/ stuff/foo相同的文件,問題是,當我嘗試這樣做,我是收到以下錯誤:從任何路徑路由到相同的文件在快遞,nodejs
Refused to execute script from 'http://localhost:8000/stuff/main.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
下面是代碼:
app.use("/", express.static(path.join(__dirname, "./../public")));
app.get("/stuff", sendIndexHTML);
app.get("/stuff/:id", sendIndexHTML);
function sendIndexHTML(req, res) {
res.sendFile(path.join(__dirname + "./../public/index.html"));
}
是您的應用SPA嗎? – Gntem
@ Mr.Phoenix這是一個使用react-router的反應應用程序 – Ferus
爲什麼不處理客戶端的路由?你已經使用react-router了,基本上你會渲染同一個頁面。 – Gntem