Files
kmtnflower/src/main.server.ts
T
DevOps QA c4e852684e
CI Pipeline / backend-test (push) Successful in 5m31s
CI Pipeline / frontend-test (push) Successful in 23s
CI Pipeline / frontend-build (push) Successful in 29s
CI Pipeline / backend-lint (push) Successful in 9s
CI Pipeline / backend-test (pull_request) Successful in 5m42s
CI Pipeline / frontend-test (pull_request) Successful in 24s
CI Pipeline / frontend-build (pull_request) Successful in 29s
CI Pipeline / backend-lint (pull_request) Successful in 9s
CI Pipeline / quality-gate (push) Successful in 2s
CI Pipeline / quality-gate (pull_request) Successful in 2s
fix: use bracket notation for process.env access (TS5.9 strict)
- src/main.server.ts: process.env['SSR_API_BASE_URL'] instead of
  process.env.SSR_API_BASE_URL to satisfy TS4111 index signature rule.
- server.spec.ts: update corresponding test assertions to match new syntax.
2026-08-07 06:03:02 +00:00

32 lines
1.2 KiB
TypeScript

import { APP_ID } from '@angular/core';
import { bootstrapApplication, BootstrapContext } from '@angular/platform-browser';
import { provideServerRendering, withRoutes } from '@angular/ssr';
import { appConfig } from './app/app.config';
import { App } from './app/app';
import { APP_CONFIG, AppConfig } from './app/services/app-config.service';
import { serverRoutes } from './app/app.server.routes';
// During SSR, the API base URL must be absolute (HttpClient runs in Node.js).
// nginx proxies /api/ to the upstream, so point at nginx (port 80) locally.
const ssrApiBaseUrl = process.env['SSR_API_BASE_URL'] || 'http://localhost:80';
const ssrAppConfig: AppConfig = { apiBaseUrl: ssrApiBaseUrl };
const serverAppConfig = {
...appConfig,
providers: [
...appConfig.providers,
{ provide: APP_ID, useValue: 'server' },
{ provide: APP_CONFIG, useValue: ssrAppConfig },
provideServerRendering(withRoutes(serverRoutes)),
],
};
/**
* Bootstrap function for server-side rendering.
* Exports a function that accepts BootstrapContext and returns ApplicationRef,
* as required by @angular/ssr's CommonEngine bootstrap signature.
*/
export default (ctx: BootstrapContext) =>
bootstrapApplication(App, serverAppConfig, ctx);