W
W
webe2018-11-17 20:27:37
Node.js
webe, 2018-11-17 20:27:37

What about relative paths to images?

Hello everyone, people help pliz.
I use express
The image is physically located in public/images/1.jpg
In the html markup, I have the following path <img src="images/1.jpg">
127.0.0.1:4000 - the image is displayed (the image refers to 127.0.0.1:4000/images/1.jpg)
127.0.0.1:4000 /category/12321 - the picture is not displayed (the picture refers to 127.0.0.1:4000/category/images/1.jpg)

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

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-11-17
@webe

Obviously don't use relative paths.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question