The embedded WebStorm web server gets 404 for each css and js file included in index.html

Here is my index.html for posterity:

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> <meta name="description" content=""> <meta name="author" content=""> <base href="/" /> <title>Cart</title> <link href="content/external/bootstrap.css" rel="stylesheet" /> <link href="content/external/bootstrap-theme.css" rel="stylesheet" /> <link href="content/external/font-awesome.css" rel="stylesheet" /> <link href="content/external/angular-toastr.css" rel="stylesheet" /> </head> <body ng-app> {{3+4}} drfg <script src="scripts/external/jquery-1.9.1.js"></script> <script src="scripts/external/bootstrap.js"></script> <script src="scripts/external/angular.js"></script> <script src="scripts/external/angular-ui-router.js"></script> <script src="scripts/external/angular-resource.js"></script> <script src="scripts/external/angular-mocks.js"></script> <script src="scripts/external/angular-toastr.tpls.js"></script> <script src="scripts/external/angular-animate.js"></script> </body> </html> 

Whenever I click run in webstorm to open in chrome, I get 404 for every javascript and css file. However, if I use the project directory and run node http-server , my site loads just fine. I can't seem to find anything in the settings related to this. Any ideas?

+5
source share
1 answer

The problem is caused by the tag in index.html:

 <base href="/"/> 

which tells the browser to resolve all the URLs on the page relative to the root of the web server ( localhost:63342 when using the embedded web server). Obviously, there are no resources there, since the embedded web server serves files from http://localhost:63342/<project root> So, you need to comment out " <base href="/"/> " to make your code work. Or modify the hosts file so that the web server serves the files from http://<some name>:63342 - see http://youtrack.jetbrains.com/issue/WEB-8988#comment=27-577559

+10
source

All Articles