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

6 comments
Comment actions Permalink

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
Comment actions Permalink

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
Comment actions Permalink

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
Comment actions Permalink

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

:)
0
Comment actions Permalink

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
Comment actions Permalink

For people with a similar problem:

I'm using fedoara 28, cinnamon desktop on a low end toshiba laptop.

I couldn't get icons to show up in a lightbox slideshow that was started by clicking an anchor img in an .html file using the webstorm browser popup.  The paths  to the  icons were referenced in a .js file:

When I opened the .html file from a file manager with a browser everything displayed and worked perfectly.  After multiple permutations of  the path from this .js file and trying to get webstorm to work I accidently hovered over the webstorm browser popup for long enough to see the info baloon appear :

 

Following that advice, I held down the shift key and clicked the opera icon and everything worked (with the path back to the original as shown in the first screen shot above).

 

0

Please sign in to leave a comment.