Doc about env variables for workspace URL etc.?


#1

Hi, just quickly looked through the docs and didn’t find any reference on how to get the workspace URL for use e.g. inside nodejs to pass it to browserSync… Is there a doc that tells me the official ENV variables?


#2

Hey @philkunz,

Pardon I don’t have a direct answer but can direct you to these docs:

:books: :snail:


#3

Ok, I looked through the links, and as far as I can see they all suggest access to process.env.ip

however c9 workspaces use a proxy to relay traffic so I don’t have access to a unique workspace ip. instead the traffic is routed to the right droplet by evaluating host headers…

because of this I asked for an env variable that provides access to the workspace URL, not the IP.

process.env.ip and process.host.ip just make sure a running server process is actually accessible through the proxy since c9 only routes specific ports by default…


#4

Maybe experiment and see if there is a process.env.url and if not maybe you can get the url from the process.env.ip:

:book: :monkey:


#6

Here you go:
https://www.npmjs.com/package/c9config

c9config

offers data about current C9.io workspace

Project Status

Build Status

Install

to install simply type

npm install c9config

Usage

var c9config = require("c9config");
c9config.isC9 // true or false depending wether on C9 or not.
c9config.print() // prints an overview of the important information to console
c9config.workspace // an object that holds the important worspace information
/* ----------- object currently looks like this ------
 *  {
 *      isC9: true,
 *      name: 'workspacename',
 *      owner: 'username',
 *      ideUrl: 'https://ide.c9.io/username/workspacename',
 *      serveUrl: 'https://workspacename-username.c9user.io'
 *  }
 */

#7

Here you go:
https://www.npmjs.com/package/c9config
However I still need to find a way to reliably get the workspacename…


#8

Does the workspacename have to be discovered programmatically or could it be hardcoded into a variable?


#9

Anything else than programmatically renders the whole package useless…

Cloud9 as an IDE is nice for quickly testing things and making small changes, because I can quickly create a new workspace… I don’t want to hardcode the workspacename every time I create a new workspace…

Cloud9 currently still lacks basic features concerning smart code validation and refactoring like WebStorm offers, so I don’t use it for big projects where the projectsize would justify to hardcode anything…

the c9config package is thought as a npm devDependency where I can quickly type things like

npm install
npm run testBrowser

right after creating the workspace from a github repo.