Built-in Webserver returns 404 for all images

Hi

I have the issue that the built-in webserver returns "HTTP/1.1 404 Not Found" for all the images that are part of the website. It's quite irritating.
How can I make the built-in webserver deliver the images correctly. What could cause the 404's is there a logfile I should consult.
The images are in a normal project-folder as the .js .css etc. files which work correct.

Thanks, best regards

5 comments

Hi there,

1) What URL is used for the actual page?

2) What failed URLs for those images are? You can take this info from "Network" tab of your browser's Developer Tools functionality.

Right now I think that this is could be because of you providing paths to images in a "wrong" way (not compatible with IDE's own build web server) -- e.g. they should be relative to current page instead of absolute.

0

Hi

1) The URL for the main page is:
http://localhost:63342/personal-website/index.html#/

2) The images are loaded from the browser with:
http://localhost:63342/assets/img/bg_pattern_comp.jpg
which results in [HTTP/1.1 404 Not Found 1ms]

in html/css I use the following path:
/assets/img/bg_pattern_comp.jpg

removing the first Slash doesn't change anything.


Edit:
It seems obvious that the path for images is missing the "personal-website" part. URLs with http://localhost:63342/personal-website/assets/img/... do work. Now why are the image URLs missing the "personal-website" part?

0

Compare these URLs -- you should see what part is missing:
http://localhost:63342/personal-website/index.html
http://localhost:63342/assets/img/bg_pattern_comp.jpg

Proper URL for images should be
http://localhost:63342/personal-website/assets/img/bg_pattern_comp.jpg

When using built-in web server the URL is built this way: http://localhost:63342/YOUR_PROJECT_NAME/rest/of/url/page.html.YOUR_PROJECT_NAME is needed for web server to recognize what files to serve (what project to use) when more than one project is in use/opened.

You have 2 choices here:

1) Alter paths to the images so that proper URL is built by the browser when requesting images. You will have to play around a bit with them -- I cannot give you exact answer (especially without seeing your code and trying few variants myself).

2) (preferred as more portable / close to real word scenario) Use http://YOUR_PROJECT_NAME:63342/rest/of/url/page.html kind or URLs. For that:

A) Edit your hosts file and add an entry so that YOUR_PROJECT_NAME is pointing to localhost, e.g.

127.0.0.1  personal-website

B) Create new Deployment entry (Settings | Deployment) of "In Place" type and mark it as Default for this project. The website URL should be http://personal-website:63342/ . This will tell IDE to use it instead of default http://localhost:63342/personal-website/

0

Thanks! I did 2) and it works as supposed now.

:)
0

Had a similar problem and logged it here: https://youtrack.jetbrains.com/issue/WEB-28826

But the solution was to add a meta tag for no-referrer. Somehow the newest webstorm fails to server resources with a referrer -- adding this helped: <meta name="referrer" content="no-referrer" />

However, images loaded from a src, etc still fail

0

Please sign in to leave a comment.