Skip to content

[C3/wrangler] Fix Angular localhost SSR blocking in development mode#12648

Merged
petebacondarwin merged 2 commits intomainfrom
pbd/fix-angular
Feb 24, 2026
Merged

[C3/wrangler] Fix Angular localhost SSR blocking in development mode#12648
petebacondarwin merged 2 commits intomainfrom
pbd/fix-angular

Conversation

@petebacondarwin
Copy link
Contributor

@petebacondarwin petebacondarwin commented Feb 23, 2026

Fixes the Angular C3 e2e tests that were quarantined due to URL with hostname "localhost" is not allowed. errors.

Recent versions of Angular's AngularAppEngine block serving SSR on localhost by default. See angular/angular-cli#32516.

This PR fixes it by passing allowedHosts: ["localhost"] to the AngularAppEngine constructor in server.ts:

const angularApp = new AngularAppEngine({
    allowedHosts:['localhost'],
});

This approach is better than modifying angular.json because:

  • No assumptions about the user's angular.json structure (important for autoconfig)
  • No need to force --configuration development in build scripts
  • Works across all three integration paths (C3 pages, C3 workers, wrangler autoconfig)

It is safe to hard code this allowed host because in Cloudflare production deployments it is never possible for localhost to hit the deployed server code.

Also unquarantines all three Angular C3 e2e tests.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: No user-facing docs changes needed; this fixes internal scaffolding behavior

Open with Devin

@changeset-bot
Copy link

changeset-bot bot commented Feb 23, 2026

🦋 Changeset detected

Latest commit: 56920b5

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@claude
Copy link
Contributor

claude bot commented Feb 23, 2026

Claude encountered an error —— View job


Reviewing Changeset

  • Read changeset guidelines
  • Review changeset file
  • Validate against criteria
  • Post review feedback

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 23, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@12648

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@12648

miniflare

npm i https://pkg.pr.new/miniflare@12648

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@12648

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@12648

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@12648

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@12648

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@12648

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@12648

wrangler

npm i https://pkg.pr.new/wrangler@12648

commit: 56920b5

Copy link
Member

@dario-piotrowicz dario-piotrowicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! 😃

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Feb 23, 2026
@petebacondarwin petebacondarwin force-pushed the pbd/fix-angular branch 2 times, most recently from 8b323ca to 087c86f Compare February 23, 2026 22:48
@petebacondarwin petebacondarwin marked this pull request as ready for review February 23, 2026 22:49
@petebacondarwin petebacondarwin requested a review from a team as a code owner February 23, 2026 22:49
@petebacondarwin petebacondarwin force-pushed the pbd/fix-angular branch 2 times, most recently from 8b323ca to 13066f6 Compare February 23, 2026 22:53
Copy link
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Could you please sync the PR description with the latest version of the code?

@petebacondarwin petebacondarwin changed the base branch from main to vicb/e2e-fix February 24, 2026 09:47
Base automatically changed from vicb/e2e-fix to main February 24, 2026 09:51
Recent Angular versions block SSR on localhost by default. Instead of
modifying angular.json, this passes allowedHosts: ["localhost"] to the
AngularAppEngine constructor conditionally based on process.env.NODE_ENV,
which wrangler statically replaces with "development" during wrangler dev
and "production" during wrangler deploy. This ensures localhost is only
allowed during local development and is dead-code eliminated in production.

Also unquarantines the Angular C3 e2e tests.
The ng build was stripping the NODE_ENV condition before even getting to Wrangler.
@petebacondarwin petebacondarwin merged commit 3d6e421 into main Feb 24, 2026
34 of 36 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Feb 24, 2026
@petebacondarwin petebacondarwin deleted the pbd/fix-angular branch February 24, 2026 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants