Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/angular/ssr/src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,15 @@
*/

declare const ngDevMode: boolean | undefined;

/**
* Indicates whether the application is operating in server-rendering mode.
*
* `ngServerMode` is a global flag set by Angular's server-side rendering mechanisms,
* typically configured by `provideServerRendering` and `platformServer` during runtime.
*
* @remarks
* - **Internal Angular Flag**: This is an *internal* Angular flag (not a public API), avoid relying on it in application code.
* - **Avoid Direct Use**: This variable is intended for runtime configuration; it should not be accessed directly in application code.
*/
declare const ngServerMode: boolean | undefined;
6 changes: 6 additions & 0 deletions packages/angular/ssr/src/routes/route-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ export const SERVER_ROUTES_CONFIG = new InjectionToken<ServerRoute[]>('SERVER_RO
* @developerPreview
*/
export function provideServerRoutesConfig(routes: ServerRoute[]): EnvironmentProviders {
if (typeof ngServerMode === 'undefined' || !ngServerMode) {
throw new Error(
`The 'provideServerRoutesConfig' function should not be invoked within the browser portion of the application.`,
);
}

return makeEnvironmentProviders([
{
provide: SERVER_ROUTES_CONFIG,
Expand Down