I'm applying SSR to a pre-existing Angular project. In the previous Client Side Rendering CSR implementation, I used the global variable window to handle ENV VARS for one build - multiple deployments CI/CD purposes following this article.
I tried using a custom service to pass the env vars to app.modules.ts using the APP_INITIALIZER with no success because the usage of envirement with forRoot() will be called way before my service. Also, webpack can't help in this situation because of one build - multiple deployments requirment.
As the example bellow I tried to inject the EnvironmentService in a module but it seems that data isn't fetched yet from the file as metioned in the article above.
import { EnvironmentService } from './environments/EnvironmentService';
let envService: EnvironmentService;
@NgModule({
declarations: [...],
imports: [ServerLogModule.forRoot(envService.ENV_VARS)],
providers: [...]
})
export class AppModule {}
ServerLogModule.forRoot()mandatory? I mean is it possible to change the code in the service, or is the service being imported from a third party library? Can you add the code of youServerLogModule?forRootand I solve them there. The problem now is with the many third-party modules such asServerLogModulein the example above