You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which @angular/* package(s) are the source of the bug?
platform-server, Don't known / other
Is this a regression?
Yes
Description
Indeed, several things about SSR need to be documented, for example since the move from @nguniversal/express-engine to @angular/ssr the express tokens were lost:
I had to search the internet for a while to understand that I had to add the "src/express.tokens.ts" file now because it no longer comes in the @angular/ssr package and that's what I did
ERROR TypeError: Cannot read properties of null (reading 'status')
at _NotFoundPageComponent (/Workspace/hittten/angularSSR17/src/app/pages/not-found-page/not-found-page.component.ts:17:21)
Angular 16 code (working):
import{RESPONSE}from"@nguniversal/express-engine/tokens";import{Response}from"express";constructor(
@Optional() @Inject(RESPONSE)privateresponse: Response,
@Inject(PLATFORM_ID)privateplatformId: object,){if(isPlatformServer(this.platformId)){this.response.status(404)}else{console.error(`response status code 404`)}}
Angular 17 code (not working):
import{InjectionToken}from'@angular/core';import{Request,Response}from'express';constREQUEST=newInjectionToken<Request>('REQUEST');constRESPONSE=newInjectionToken<Response>('RESPONSE');constructor(
@Optional() @Inject(RESPONSE)privateresponse: Response,
@Inject(PLATFORM_ID)privateplatformId: object,){if(isPlatformServer(this.platformId)){this.response.status(404)}else{console.error(`response status code 404`)}}
Info
basically I have created a project like this:
npx @angular/cli@17.0.8 new angularSSR17 --ssr --routing --scss --skip-tests
cd angularSSR17
npm i -D firebase-tools@13.0.2
ng g c pages/homePage
ng g c pages/aboutPage
ng g c pages/notFoundPage
I also intent to provide express tokens in /server.ts: provide: REQUEST, useValue: req }, { provide: RESPONSE, useValue: res }, which is not necessary to do in angular 16, but it doesn't work either.
Which @angular/* package(s) are the source of the bug?
platform-server, Don't known / other
Is this a regression?
Yes
Description
Indeed, several things about SSR need to be documented, for example since the move from @nguniversal/express-engine to @angular/ssr the express tokens were lost:
https://github.com/angular/universal/blob/e798d256de5e4377b704e63d993dc56ea35df97d/modules/express-engine/tokens/injection-tokens.ts
I had to search the internet for a while to understand that I had to add the "src/express.tokens.ts" file now because it no longer comes in the @angular/ssr package and that's what I did
I have published a repo with the minimum to recreate the SSR problem with angular 17: https://github.com/hittten/angularSSR17
Clone & Setup:
Log
Navigate to http://localhost:4200/404
Angular 16 code (working):
Angular 17 code (not working):
Info
basically I have created a project like this:
npx @angular/cli@17.0.8 new angularSSR17 --ssr --routing --scss --skip-tests cd angularSSR17 npm i -D firebase-tools@13.0.2 ng g c pages/homePage ng g c pages/aboutPage ng g c pages/notFoundPage
I also disable pre-render in angular.json:
and I have done the settings of the routes for lazy load. I have not installed @angular/fire because it is not necessary to recreate the SSR error.
Please provide a link to a minimal reproduction of the bug
https://github.com/hittten/angularSSR17
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
I also intent to provide express tokens in /server.ts:
provide: REQUEST, useValue: req }, { provide: RESPONSE, useValue: res },
which is not necessary to do in angular 16, but it doesn't work either.The text was updated successfully, but these errors were encountered: