Using another host (virtualhost) with javascript debugger.

Hello, so here are my settings:

Preferences -> Debugger -> Javascript Port 63342
Custom configuration: http://otherHostName:63342/web/index.html
Chrome plugin: Post: 63342, Host: otherHostName

If I launch with localhost, everything is fine and I can debug. If I launch with
otherHostName, I land on a "404 Not Found - WebStorm 7.0.2" page.

I did add otherHostName in the host file.

host:
127.0.0.1     otherHostName

Any ideas why it's not working?

12 comments

Hi there,

So you are using built-in web server.

URL: http://localhost:63342/web/index.html
In this URL "web" is the PROJECT NAME (that's how IDE identifies what project to use when serving files).

Alternative URL: http://web:63342/index.html
In this URL PROJECT NAME is the host name.

So..
http://localhost:63342/PROJECT_NAME/index.html
is the same as
http://PROJECT_NAME:63342/index.html

0

Hello Andriy,

Thank you very much for your answer. A temporary solution would be to name the project the same than the origin I want to send to the server e.g. otherHostName.

What I d'ont understand, Is why http://otherHostName:63342/PROJECT_NAME/index.html is not working, since in my host file, otherHostName is pointing to 127.0.0.1 (same as localhost). Hopefuly you got a solution for that also!! Thanks again.


EDIT: I just tried http://web:63342/index.html and it does not work.

0
What I d'ont understand, Is why http://otherHostName:63342/PROJECT_NAME/index.html is not working, since in my host file, otherHostName is pointing to 127.0.0.1 (same as localhost). Hopefuly you got a solution for that also!! Thanks again.

When IDE sees something different than "localhost" as domain name, it applies different URL structure (the olready mentioned http://localhost:63342/PROJECT_NAME/index.html vs http://PROJECT_NAME:63342/index.html -- as you can see there is NO "PROJECT_NAME" ("web" in your case) in the path). It should be http://otherHostName:63342/index.html in such case -- and this assumes that "otherhostName" IS the project name.

EDIT: I just tried http://web:63342/index.html and it does not work.

This  assumes that your project name is "web" -- correct?

It works perfectly fine here -- tried that on multiple occasions in the past (assuming that you have pointed "web" to 127.0.0.1 in your hosts  file or local DNS server).

To avoid confusion, better show your real host names/project names.

0

Bazzik a écrit:

What I d'ont understand, Is why http://otherHostName:63342/PROJECT_NAME/index.html is not working, since in my host file, otherHostName is pointing to 127.0.0.1 (same as localhost). Hopefuly you got a solution for that also!! Thanks again.

When IDE sees something different than "localhost" as domain name, it applies different URL structure (the olready mentioned http://localhost:63342/PROJECT_NAME/index.html vs http://PROJECT_NAME:63342/index.html -- as you can see there is NO "PROJECT_NAME" ("web" in your case) in the path). It should be http://otherHostName:63342/index.html in such case -- and this assumes that "otherhostName" IS the project name.

Ahh ok! This explains why I've had so much problems trying to do it with a virtualhost. 

EDIT: I just tried http://web:63342/index.html and it does not work.

This  assumes that your project name is "web" -- correct?

It works perfectly fine here -- tried that on multiple occasions in the past (assuming that you have pointed "web" to 127.0.0.1 in your hosts  file or local DNS server).

To avoid confusion, better show your real host names/project names.

Yes, this is correct. So I have to point web to 127.0.0.1 in hosts file?
Sorry for the confusion, "web" is my real project name, it was by default when I checkout from SVN.

0

If I point "web" to 127.0.0.1 in my hosts it work!

But I don't understand why otherHostName is not working since it's also pointing to 127.0.0.1 in my hosts...I know it's not the name of the project, but even if "web" is the name of my project, both otherHostName and "web" are pointing to 127.0.0.1.

0

Once again: built-in web server needs to know *what project to use* to serve files from (same as proper webserver (Apache/nginx/IIS/etc) uses host name for that)..

In original URL it is provided as first segment in path ... and in 2nd one it is actually the host name:

//localhost:63342/PROJECT_NAME/index.html
//PROJECT_NAME:63342/index.html

0

Ok! I get it! Thank you very much for your precious help.

0

Hello,

I'm having another problem with this. The project name is "test" and the URL in the debug config is http://test:63342/index.html. The Debugger port is 63342 and "test" is pointing to 127.0.0.1 in the hosts file. Now it doesn't work when I try to debug. I think the problem comes from the Chrom plug-in, when I put "test" in the host input, it kind of disables the plugin and when I try to debug, I get this message: Please ensure that JetBrains IDE Support extension is          installed and enabled in Chrome.

What exactly do I have to enter in the host input? It seems like everything I enter in the host input except localhost disabled the plugin. Also I tried with localhost, but I still does not work.

I know I could use localhost:63342/test, but I really need to use a custom hostname.

Hopefully you can help :D


Thank you!

0

Ok so I found the solution. I need to point 127.0.0.1 to "test", not the opposite.

0

You can simply rename your project to something more unique compared to general "test"...

0

Please can you provide your hosts file contents?

0

Here it is:

127.0.0.1                 localhost

255.255.255.255       broadcasthost

::1                           localhost

fe80::1%lo0             localhost

127.0.0.1                 test

0

Please sign in to leave a comment.