D
D
Dvorak2016-10-08 13:47:25
Node.js
Dvorak, 2016-10-08 13:47:25

Why doesn't express show pictures?

I give the static like this:

app.use('/add', express.static(__dirname + '/front-end/add.html'));

The HTML page is loading, but the images are not loading. At the same time, I checked the paths and names of the pictures a hundred times. Tried to somehow move them. Still no way

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mark Doe, 2016-10-08
@mourr

Because it gives 404 to your pictures, because the only static it knows (based on your piece of code) is /front-end/add.html
If the pictures are in a separate folder, it makes sense to set express.static on them as well
Or so

app.use('/images',express.static(__dirname + '/front-end/images'));

S
sasha, 2016-10-08
@madmages

try to open the picture directly in the browser, when you see the garbage, then think about how the express should send the picture using this url

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question