Skip to content

How to expose angular port 4200? #994

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Disane87 opened this issue Sep 17, 2019 · 10 comments
Closed

How to expose angular port 4200? #994

Disane87 opened this issue Sep 17, 2019 · 10 comments

Comments

@Disane87
Copy link

First of all, thank you for this awesome project!
Now i setup the code-server to extend my dev setup and have the ability to code on my ipad. I managed to get all of it working (event with angular cli). But now I want to open the page. Angular opens a port 4200 with hot reload etc. How can I expose this port to open the page on my localhost (work machine).

I've run the code-server v2 (latest v2) within a docker container.

@code-asher
Copy link
Member

code-asher commented Sep 17, 2019

For now you'll have to expose the port yourself on the Docker container. Something like -p 127.0.0.1:4200:4200.

Tracking for having a way built into code-server to proxy ports is here: #512

@Disane87
Copy link
Author

I've already did that but the connection is still refused. Even with curl in the container itself it's still refusing the connection.

@code-asher
Copy link
Member

code-asher commented Sep 18, 2019 via email

@Disane87
Copy link
Author

Can we reopen this to investigate it?

@Disane87
Copy link
Author

Oh wow, today I just tested it again and now it works but nothing changed. Even the external access on the exposed port 4200 works.

@mahmoudajawad
Copy link

mahmoudajawad commented Mar 7, 2020

Skip to UPDATE2

I'm having the same issue when trying to start code-server for angular development. I have published the ports in my docker-compose.yml file as following:

version: '3.3'

services:
   code-server:
     image: code-server-ng
     volumes:
       - ./project:/home/coder/project
     ports:
       - "48080:8080"
       - "14200:4200"

However, unlike earlier comment. I can access angular app from inside code-server by getting correct output for curl localhost:4200.

Versions info:

Version: 1.41.1
Commit: f51e045cd5483561afc07694f39307fb673b6d1d
Date: 2020-01-17T22:58:55.612Z
Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36 Edg/80.0.361.66
Code Server Version: 2.1698-vsc1.41.1

UPDATE:
The published ports are purposely set to 48080, 14200 accordingly. I'm able to acccess code-server on 48080 without issues. However, can't access angular server on 14200.

UPDATE2:
It was a problem at my end. I didn't feel the need to add --disableHostCheck to ng serve since I'm binding the port to localhost already. But, then after trying it I realised it's working.

@kylecarbs
Copy link
Member

Happy to hear you got everything working! Let us know if you have any issues :)

@lawrencetaur
Copy link

I have a similar question but not related to exposing.

When I run ng serve, it creates a proxy urls domain.com/proxy/4200 while the index loads, the dependant files styles.css, main.js are loading from domain.com and result in a 404. Where am I going wrong? I tried changing baseurl to proxy/4200 and still doesnt work.

@code-asher
Copy link
Member

code-asher commented Aug 23, 2021 via email

@shubham8550
Copy link

shubham8550 commented Jul 12, 2023

changing css location and " ng serve --host 0.0.0.0 --disable-host-check" fixed issues for me

PS: It did work at first and now its not working idk why it stopped working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants