0

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.

Dave
  • 15,639
  • 133
  • 442
  • 830
  • 1
    Import the angular.json file to your service and read it. Checkout this question https://stackoverflow.com/questions/47206924/angular-5-service-to-read-local-json-file – Mehyar Sawas Jan 06 '23 at 21:58
  • This doesn't apply though, right? The post talks about loading a static JSON asset, which must be defined in angular.json. I'm talking about reading the angular.json file itself. Let me know if I'm misinterpreting the intention of the linked post. – Dave Jan 09 '23 at 16:09

0 Answers0