CLI + Angular2 + C9 = Not Working


#1

I’ve seen this topic posted a number of times on this forum but nothing has resolved the issue for me.

I install CLI and launch a new project using all of the generic commands on cli.angular.io.

When I launch ng serve or even ng serve --host 0.0.0.0 --port 8080, I get “Invalid Host Header” when previewing.

A few websites have suggested: "ng serve --host 0.0.0.0 --public-host workspace-username.c9users.io but this isn’t working for me either. When I do this the website hangs (i.e. the preview pane shows that it’s loading the site indefinitely, without it actually ever loading).

Any other suggestions I can try? Node, NPM, CLI are all latest version. Thanks.


#2

try using --disable-host-check flag https://github.com/angular/angular-cli/wiki/serve#options

ng serve --host 0.0.0.0 -port 8080 --disable-host-check

#3

Thanks - but should have mentioned - already tried this with same result. Website loads (hangs) indefinitely.


#4

I’ve tried running

npm install -g @angular/cli
ng new ng
cd ng
ng serve --host 0.0.0.0 -port 8080 --disable-host-check

on an workspace with 1G ram, and it opened Welcome to app! page correctly.
So i think it must be either an error in the code you added, or ng serve running out of memory if your workspace have less than 1G.


#5

I followed your exact series of steps, but had to additionally update Node to allow for cli to install:

nvm install 6
nvm alias default 6

Before trying anything, I deleted my workspace and started a new one, resizing it to include 1gb ram.

Same result. Preview pane loads continuously and shows blank.

Am I accessing the preview using the wrong URL? I’m just using the preview button at the top which gets me to app-name-username.c9users.io.

Frustrating.


#6

I’m mistaken. After doing everything I described in my previous post, the page took a couple of minutes to load, but ultimately did load. I think the resizing to 1gb space made the difference. Also now the live reload seems to be instant so the few minutes of load time seems to be a one-time phenomenon.

Thanks for the help harutyun.