In Angular 14, how do I find the value of"publicHost" (from angular.json) within my service?

334 views Asked by At

I'm using Angular 14. In my angular.json file I have

    "serve": {
      "builder": "ngx-build-plus:dev-server",
      "configurations": {
        "production": {
    ...
        "development": {
          "browserTarget": "my-app:build:development"
        }
      },
      "defaultConfiguration": "development",
      "options": {
        "port": 4204,
        "publicHost": "http://localhost:8005",
        "extraWebpackConfig": "webpack.config.js"
      }
    },

I would like to know how I can get the value of the "publicHost" in an injectable service I have, for example

@Injectable({
  providedIn: 'root'
})
export class AppService {

    public getPublicHost() {
        ...
    }
}

It is not an option to return "windnow.location.host" only because this particular application runs as a remote application within a larger shell application using Angular's module federation. What I have learend is that in such a configuration, "windnow.location.host" only returns the URL of the parent (shell) application and not the remote.

0

There are 0 answers