Skip to content

en external problem about how set angular2 host as “localhost or a fixed ip #8

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
keryhu opened this issue May 25, 2016 · 4 comments

Comments

@keryhu
Copy link

keryhu commented May 25, 2016

hello,

I would like to ask a question , if i build a spring-boot angular2 in docker .

I can set the host in spring-boot server , as "localhost /192.168.1.110",

How set it in angular2 , that can be easily tested locally or 192.168.1.110 env?

@keryhu keryhu changed the title en external problem about how to set a fixed ip in docker environment en external problem about how set angular2 host as “localhost or a fixed ip May 25, 2016
@akirasosa
Copy link
Contributor

@keryhu
You just run npm start. Then, webpack-dev-server will be started. It is configured to use port 3001 as default.

You can access it with something like http://yourhost:3001/main.js .

@keryhu
Copy link
Author

keryhu commented May 26, 2016

@akirasosa yes,
I can think of the current way is that host configuration localhost ,, when development is complete, change to a fixed ip

@akirasosa
Copy link
Contributor

@keryhu
In production, you can use any servers such as S3, CloudFront and your own Nginx server to host your js files. I use CloudFlare for my demo app. The main.js is served from https://cdn.hana053.com/main.5cb9cd7281b9f956d6fa.js .

Then, all you have to do is just configuring boot-app to point the location js files hosted.
https://github.com/springboot-angular2-tutorial/boot-app/blob/ddf84b0a7e1e98f47f6cbdbc1ca09a049d763ff1/src/main/resources/application.yml#L87

P.S.

In develop mode, you may want to configure the host of webpack-dev-server as 0.0.0.0. Then, you can access it when angular2-app is running in virtual machine or docker.

@keryhu
Copy link
Author

keryhu commented May 26, 2016

Ah,yes, webpack-dev-server as 0.0.0.0 that 's what I urgently needed ! Thanks very much !

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

2 participants