Set the root path without project name

How do I fix the path that chrome sees on my projects? For example the url in the browser looks like:

http://localhost:63342/myproject/index.html

I want it to look like: 

http://localhost:63342/index.html

I've tried changing the Content Resource Root but it doesn't make a difference. It's set to /home/"username"/myproject,

If I can correct this my links to stylesheets and images will work correctly and I'll actually be able to use WebStorm. 

I'm using a Ubuntu 16.04 64 bit workstation, and Webstorm 2017.3.2

5 comments
Comment actions Permalink


The built-in web server serves files from http://localhost:63342/<project name> (this is done to allow serving several projects at once).
There is no way to set it up to use http://localhost:63342/ URL. But you can configure it to use URLs like http://<project_name>:<port> where the 'project name' is a name specified in hosts file, like 127.0.0.1 project_name. See https://youtrack.jetbrains.com/issue/WEB-8988#comment=27-577559.

But, rather than changing hosts, etc., I'd suggest using different server (Apache, etc.) to host your application if you like it being served from the root.

1
Comment actions Permalink

Thanks Elena,

Out of curiosity, why do you recommend using a different server over changing the hosts file?

best,

-james

0
Comment actions Permalink

The built-in webserver is a simple solution for development - it has some limitations as compared to full-functional web server, and you will still need a different server for production. Also, we have some reports regarding performance degradation when debugging applications with modified hosts.

1
Comment actions Permalink

The problem with the way JetBrains has implemented this across their tools is that in order to use the convenient debugger+web server for a project (e.g. I use WebStorm), it injects the project name into the URL path instead of just using a different port. This affects how all the project assets are addressed since the project name will not be in the hosted URL. This is a bad design choice by JetBrains and causes a cumbersome work around on our part. 

The best solution is to simply not introduce the project name into the path. Use ports. The overwhelming majority of us are not going to be juggling simultaneous projects anyway so that use case is not prevalent. But not being able to use constant asset paths, for example, in css files because of this, that is a problem.

5
Comment actions Permalink

I know this is an older topic but I stumbled over that problem just a few minutes ago, because I want to include custom web fonts and the URL just breaks everything in the preview.

That currently renders the builtin server somehow useless for me and I don't think custom webfonts are an edge case.

I'd also like to see different ports per project instead.

0

Please sign in to leave a comment.