W
W
WapSter2020-05-26 17:52:18
Node.js
WapSter, 2020-05-26 17:52:18

Static files in express?

I include static files like this

app.use('/',express.static(path.join(__dirname, 'public')))
, everything works great. But when I start using dynamic routes, the path to static files in the page resources changes from http://localhost:3000/style.cssto http://localhost:3000/information/style.css. Route looks like '/information/:id'. By itself, the route works fine and opens the page I need. Can you suggest what could be causing this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Robur, 2020-05-26
@wapster92

your html paths are relative.
type href="file.css"
put absolute href="/file.css"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question