🔥 feat(web-sdk_angular): Add Angular Universal (SSR) support [NT-3467]#330
Draft
Felipe Mamud (fmamud) wants to merge 1 commit into
Draft
🔥 feat(web-sdk_angular): Add Angular Universal (SSR) support [NT-3467]#330Felipe Mamud (fmamud) wants to merge 1 commit into
Felipe Mamud (fmamud) wants to merge 1 commit into
Conversation
Wiz Scan Summary
To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension. |
| "@contentful/rich-text-types": "^17.2.7", | ||
| "contentful": "^11.12.4", | ||
| "express": "5.2.1", | ||
| "express-rate-limit": "8.2.1", |
There was a problem hiding this comment.
The following vulnerability impacts express-rate-limit versions <8.2.2: CVE-2026-30827.
It can be remediated by updating to version 8.2.2 or higher.
To ignore this finding as an exception, reply to this conversation with #wiz_ignore reason
If you'd like to ignore this finding in all future scans, add an exception in the .wiz file (learn more) or create an Ignore Rule (learn more).
To get more details on how to remediate this issue using AI, reply to this conversation with #wiz remediate
Suggested change
| "express-rate-limit": "8.2.1", | |
| "express-rate-limit": "8.2.2", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
implementations/web-sdk_angularwith Angular Universal SSR. Server-side SDK initialisation uses@contentful/optimization-nodevia a conditional dynamic import; the browserkeeps using
@contentful/optimization-webunchanged.TransferState. Anonymous-id continuity is preserved across runtimes via aSet-Cookiewritten by the server preflight.node-sdkreference:express@5.2.1+express-rate-limit@8.2.1, mounted on@angular/ssr/node'sAngularNodeAppEngine.What changed
src/main.server.ts,src/server.ts,src/app/app.config.server.ts,src/app/app.routes.server.ts.angular.jsongainsserver,outputMode: "server", andssr.entry.package.jsonadds@angular/ssr,@angular/platform-server,express,express-rate-limit, and astartscript.src/app/services/optimization-server.tsdynamic-imports@contentful/optimization-node, reads consent + anonymous-id cookies from Angular'sREQUESTtoken, calls
forRequest({ consent }).page(), runsresolveOptimizedEntry()per baseline, persists the anonymous-id back viaRESPONSE_INIT, and stampsTransferState.provideClientHydration(withEventReplay())on the browser side.src/app/services/entry.tsfalls back to TransferState when the browser SDK is absent (server runtime).src/app/services/contentful-client.tsloadEntriesshort-circuits when the server already fetched the baselines.NgContentfulOptimizationconstructs@contentful/optimization-webonly whenisPlatformBrowser. SDK call sites in components and services use null-safechains so server render skips browser-only side effects without a separate adapter type.
Why
Per the ticket implementation notes, "the existing browser SDK works cleanly in the SSR context without special-casing" was preferred — but the browser SDK touches
localStorageat construction, which crashes server-side. The fallback the notes explicitly allow is used:@contentful/optimization-nodefor server-side SDK initialisation, conditional dynamic imports for runtime separation. There are no unsafe type assertions: server modules use the Node SDK with its real types; browser modules use the Web SDK with its real types; onlyResolvedEntrydata crosses the boundary, viaTransferState.A future Angular adapter package will extract these helpers into
@contentful/optimization-angularand replace the in-impl wiring.Test plan
pnpm implementation:run -- web-sdk_angular typecheckpnpm exec eslint implementations/web-sdk_angularpnpm implementation:run -- web-sdk_angular build— emitsdist/web-sdk_angular/{browser,server}/pnpm implementation:run -- web-sdk_angular dev+ mocks):ng-server-context="ssr"cookie: app-personalization-consent=granted:data-ctfl-variant-index,data-ctfl-optimization-idpopulated server-side;Set-Cookie: ctfl-opt-aid=…returneddata-ctfl-baseline-idrendered; browser SDK takes over after hydration/page-tworoute also serves SSR'd HTMLResolving optimized entry for baseline entry …andhas been resolved to variant entry …lines per requesthttp://localhost:4200in a browser and exercise consent / identify / reset / live-updates / preview panel post-hydrationpnpm test:e2e:web-sdk_angular(existing scenarios were authored against the SPA; SSR-specific assertions are intentionally deferred)