问题
I have a Javascript project that I work on in cloud9 IDE online, and I wanted to test my code using testem npm module: npmjs.org/package/testem together with libraries like Mocha or Jasmine.
I was following this tutorial on net tuts +
I have installed the testem npm module, but when I run it using command "testem" in cloud9's terminal window testem asks me to open a new tab in "localhost:7357"
Generally to preview workspace files in cloud9 I would go to https://c9.io/username/folders.../workspace/folders.../index.html
Since I am on the cloud9 server, I wanted to know if it is possible to open this 'localhost' link from the browser, and if yes, how would I do it?
(I tried 'localhost', '127.0.0.1', '0.0.0.0' inside cloud9's IDE, but it did not work).
Maybe I can access it differently?
Like "username.cl9.io/workspace:PORT" ?
If not, maybe it is possible to provide a link and port to testem (and by any chance how would one do it ?). I know in cloud9 you can use process.env.IP and process.env.PORT to provide to different modules, but no idea on how to open such files later from the browser.
Any help will be appreciated.
回答1:
If you are running a node process: http://workspacename.username.c9users.io will be the link to get to it.
If you want to preview a particular file in the workspace: https://c9users.io/username/workspacename/workspace/filename.html
Example:
My name is bob, and my project name is mycoolproject.
Running node service link - http://mycoolproject.bob.c9users.io
Direct file preview link - https://c9users.io/bob/mycoolproject/workspace/index.html
回答2:
If you run testem with the host and port variables:
testem --host $IP -p $PORT
You should be able to connect from your browser by going to the root of your external server:
http://workspace.username.c9users.io/
回答3:
I know this is a really late response, but I get the feeling that you simply just need the right hostname and you'll be in business. My method for getting C9's hostname is as follows:
If you open up a terminal and access the mysql command line by typing in
mysql-ctl start
followed by
mysql-ctl cli
which will take you to the MySQL command line interface, and then you can run this query:
SHOW VARIABLES WHERE Variable_name = 'hostname';
It will give you back your hostname under the column hostname which should look something like this:
yourUsername-yourProjectName-XXXXXXX
where the X
's form a 7 digit number. You can use that as your hostname instead of localhost or 127.0.0.1 (which have never worked for most people and I'm not sure why people on other SO posts consistently suggest those). I have used this hostname before to sync my PHP scripts with my MySQL databases (before C9 implemented a built-in phpMyAdmin), and always had success with it.
回答4:
on C9.io its simple for me.
Just open the file(i.e server.js or index.js or index.html) and click on preview button.
WAO you are done. :)
hope it help.
I created an application using node + express + react and then i created a simple server.js and click the preview, it open the browser.
回答5:
sorry for that, you can't!
Available ports on a hosted Cloud9 workspace
If you're developing a server application, please note that you need to listen to 0.0.0.0 ($IP) and 8080 ($PORT). Listening to this port will enable your app to be viewable at http://-.c9users.io
You can also bind to ports 8081, and 8082, which can be accessed by http://-.c9users.io:8081 and http://-.c9users.io:8082 respectively.
Please note that 8080, 8081, and 8082 are the only available ports on a hosted Cloud9 workspace.
https://docs.c9.io/docs/run-an-application
来源:https://stackoverflow.com/questions/15990818/how-to-connect-to-the-process-running-on-localhost-that-is-inside-of-cloud9-se