Skip to content

Request and request context missing during ssr #29914

Closed as not planned
Closed as not planned
@heddendorp

Description

@heddendorp

Which @angular/* package(s) are the source of the bug?

platform-server

Is this a regression?

Yes

Description

During SSR both the REQUEST and REQUEST_CONTEXT are null.
Even though the PLATTFORM_ID is in fact server.

The log I get is

null                      
null                      
'server'               
true             

For the following code

  const requestContext = inject(REQUEST_CONTEXT) as Context | null;
  console.dir(requestContext);
  const angularRequest = inject(REQUEST);
  console.dir(angularRequest);
  const platformId = inject(PLATFORM_ID);
  console.dir(platformId);
  console.log(isPlatformServer(platformId));

That code is at https://github.com/evorto-app/app/blob/ce0e4f7cc83f97cef3757229b08eb4b69545ac4a/src/app/core/auth-token.interceptor.ts#L8-L14

I call SSR like https://github.com/evorto-app/app/blob/ce0e4f7cc83f97cef3757229b08eb4b69545ac4a/src/server/app.ts#L115-L127

Happy to provide more information, I am very sure this used to work.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw


Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 19.2.4
Node: 22.13.0
Package Manager: yarn 4.5.3
OS: win32 x64

Angular: 19.2.3
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.1902.4
@angular-devkit/build-angular     19.2.4
@angular-devkit/core              19.2.4
@angular-devkit/schematics        19.2.4
@angular/cdk                      19.2.6
@angular/cli                      19.2.4
@angular/material                 19.2.6
@angular/material-luxon-adapter   19.2.6
@angular/ssr                      19.2.4
@schematics/angular               19.2.4
rxjs                              7.8.2
typescript                        5.8.2
zone.js                           0.15.0

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions