Cf worker setup#295
Open
eneajaho wants to merge 6 commits into
Open
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Dissolves the standalone cf-worker NX project and consolidates all Cloudflare Worker build targets (build-cf-worker, preview-cf-worker, deploy-cf-worker, cf-typegen) directly into the movies project. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Move the movies app SSR onto the @angular/ssr AngularAppEngine +
createRequestHandler flow (app.routes.server.ts), replacing the
zone-less CommonEngine routing path.
Fix two SSR runtime bugs surfaced on the Worker:
- The CF FastSVG loader fetched icons from `${origin}/${name}.svg`,
which missed the static asset, fell through to the `**` route and
redirected to `/page-not-found`. fetch() followed the redirect and
triggered a full SSR render per icon, recursing exponentially and
exhausting the Worker subrequest budget (which also broke TMDB
fetches). Fetch from `/assets/svg-icons/${name}.svg` instead.
- Guard the RxState patch() reducers (movie/discover/person state)
with `|| {}` so the first/loading emission no longer logs
"Patch: original value undefined is not an object." warnings.
Drop the leftover zone-less routing/zone helpers.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Allow all hosts with trustProxyHeaders so the Worker renders behind Cloudflare's proxy, set NG_ALLOWED_HOSTS / NODE_VERSION wrangler vars, and drop the dead withDisabledInitialNavigation comments. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Wrap the Cloudflare Worker request handler with a Workers KV page cache (binding `ssr_cache`): GET requests that render to 200 HTML are stored with a 120s expirationTtl and served straight from KV on the next hit. Redirects, non-GET and non-HTML responses bypass the cache. A build-id (generated by scripts/generate-build-id.mjs before each cf-worker build) is stored as KV metadata so a new deploy ignores stale entries instead of serving HTML that references old asset hashes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
BioPhoton
reviewed
Jun 18, 2026
Comment on lines
+80
to
+88
| // setTimeout(() => { | ||
| // this.router.navigate([ | ||
| // // The pathname route seems to work correctly on SSR but when pre-rendering it is an empty string. | ||
| // // We have to fall back to document URL as a fix. | ||
| // fallbackRouteToDefault( | ||
| // this.document.location.pathname || this.document.URL, | ||
| // ), | ||
| // ]); | ||
| // }); |
Member
There was a problem hiding this comment.
Is this a left over? If yes, please lets delete it.
BioPhoton
reviewed
Jun 18, 2026
Comment on lines
+64
to
+68
| // setOptions(options: RxInputType<Record<string, string>>) { | ||
| // this.effects.register(coerceObservable(options), (queryParams) => | ||
| // this.router.navigate([], { queryParams }), | ||
| // ); | ||
| // } |
BioPhoton
reviewed
Jun 18, 2026
Member
There was a problem hiding this comment.
Nice this is cleaned up now! :)
BioPhoton
reviewed
Jun 18, 2026
Comment on lines
+69
to
+76
| // { | ||
| // provide: APP_INITIALIZER, | ||
| // useFactory: () => (): Promise<void> => | ||
| // new Promise<void>((resolve) => { | ||
| // setTimeout(() => resolve()); | ||
| // }), | ||
| // multi: true, | ||
| // }, |
BioPhoton
reviewed
Jun 18, 2026
| allowedHosts: readonly string[]; | ||
| supportedLocales: Readonly<Record<string, string>>; | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| entryPoints: Readonly<Record<string, (() => Promise<any>) | undefined>>; |
Member
There was a problem hiding this comment.
Do we know the shape of the entryPoint so typing and linting is in a good shape pls?
BioPhoton
reviewed
Jun 18, 2026
Comment on lines
+10
to
+11
| // hack to make it work - not needed on normal angular setup | ||
| ɵsetAngularAppEngineManifest(manifest); |
Member
There was a problem hiding this comment.
Could we add some more comments to make it also clear what the hack does and why it it needed?
BioPhoton
requested changes
Jun 18, 2026
BioPhoton
left a comment
Member
There was a problem hiding this comment.
Nice we progress with the SSR setup!
I found some leftover commented out code and a eslint disabling. other than this with a small PR description it looks good!
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.
No description provided.