Angular2 app public URL without port number

2.9k Views Asked by At

What I have to config to access an Angular2 app from a remote server without a port number. For example: My server where wakanda is running is www.myserver.com and my Angular2 app is reachable via localhost:8000. Now I'll use something like www.myserver.com/myapp/ to see my Angular2 app. I've found the webpack.config.js, but no idea whether this is the right place to do it or what config to set.

3

There are 3 best solutions below

0
On

Check your protractor.conf.js file. In this file change your baseUrl.

baseUrl: 'your base url',
0
On

No idea about what wakanda is, but only point you have to mind is your baseUrl, which for your localhost seems to be "/" and you want it to be "/myapp" in production.

You'll need to set it up in index.html inside the head tag like this:

<head>
  <base href="/myapp">
  ...
</head>

And in webpack config

output: {
  publicPath: '/myapp',
  ...
},
0
On

Public URLs by default map to port 80. You can specify ng serve --port 80 in your package.json file in your Angular2 directory so that the application is accessible without specifying port.