Miqez
Miqez

Reputation: 173

Node.js changing path to static files

When I am other route everything is Ok, but when a subpage is being created dynamically I get an error 500 and I do not have favicon or my js file. Why is this happening?

- 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"));

Upvotes: 0

Views: 274

Answers (2)

Hemant Rajpoot
Hemant Rajpoot

Reputation: 690

try this code

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

Upvotes: 1

Newaz Sharif
Newaz Sharif

Reputation: 424

missing bracket is may be the issue.

res.render("vehicle", { name: req.user }); // you missed the closing ')' here

Upvotes: 1

Related Questions