Reputation: 2924
I need to include my static images at html page. So I do it like that:
app.use(express.static(path.join(__dirname, 'public')));
And put all my images inside public under '/images' folder. So then I call it like this:
<img src="images/image_1.jpg"/>
But my path when page loaded looks like:
http://localhost:3000/product/images/image_1.jpg
Why did page url path http://localhost:3000/product/ added before img src?
Upvotes: 0
Views: 1365
Reputation: 318332
If you're already at http://localhost:3000/product
clicking a link with the href images/image_1.jpg
takes you to http://localhost:3000/product/images/image_1.jpg
as the URL is relative.
You probably wanted to use absolute paths instead
<img src="/images/image_1.jpg" />
Upvotes: 2