gpt4 book ai didi

javascript - Node.js 更改静态文件的路径

转载 作者:行者123 更新时间:2023-12-01 02:49:14 24 4
gpt4 key购买 nike

当我在其他路线时,一切正常,但是当动态创建子页面时,我收到错误 500,并且我没有 favicon 或我的 js 文件。为什么会发生这种情况?

- My route
app.get("/:id/vehicle", isLoggedIn, (req, res) => {
res.render("vehicle", { name: req.user }); <- edited, thanks
});

- Error message, code 500
GET http://localhost:3000/xxx/common/js/main.js net::ERR_ABORTED

- Path to public directory
app.use(express.static(path.join(__dirname, "/public")));
app.use(favicon(__dirname + "/public/favicon.ico"));

最佳答案

试试这个代码

app.use(express.static(path.join(__dirname, "public")));

关于javascript - Node.js 更改静态文件的路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47074598/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com