File tree Expand file tree Collapse file tree 5 files changed +25
-12
lines changed
wrangler/src/autoconfig/frameworks Expand file tree Collapse file tree 5 files changed +25
-12
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " create-cloudflare " : patch
3+ " wrangler " : patch
4+ ---
5+
6+ Fix Angular scaffolding to allow localhost SSR in development mode
7+
8+ Recent versions of Angular's ` AngularAppEngine ` block serving SSR on ` localhost ` by default. This caused ` wrangler dev ` / ` wrangler pages dev ` to fail with ` URL with hostname "localhost" is not allowed. `
9+
10+ The fix passes ` allowedHosts: ["localhost"] ` to the ` AngularAppEngine ` constructor in ` server.ts ` , which is safe to do even in production since Cloudflare will already restrict which host is allowed.
Original file line number Diff line number Diff line change @@ -167,9 +167,6 @@ function getFrameworkTestConfig(pm: string): NamedFrameworkTestConfig[] {
167167 } ,
168168 nodeCompat : false ,
169169 flags : [ "--style" , "sass" ] ,
170- // TODO: currently the Angular tests are failing with `URL with hostname "localhost" is not allowed.`
171- // we need to investigate this so that we can un-quarantine the Angular tests
172- quarantine : true ,
173170 } ,
174171 {
175172 name : "angular:workers" ,
@@ -189,9 +186,6 @@ function getFrameworkTestConfig(pm: string): NamedFrameworkTestConfig[] {
189186 } ,
190187 nodeCompat : false ,
191188 flags : [ "--style" , "sass" ] ,
192- // TODO: currently the Angular tests are failing with `URL with hostname "localhost" is not allowed.`
193- // we need to investigate this so that we can un-quarantine the Angular tests
194- quarantine : true ,
195189 } ,
196190 {
197191 name : "gatsby:pages" ,
@@ -790,9 +784,6 @@ function getExperimentalFrameworkTestConfig(
790784 nodeCompat : false ,
791785 flags : [ "--style" , "sass" ] ,
792786 verifyTypes : false ,
793- // TODO: currently the Angular tests are failing with `URL with hostname "localhost" is not allowed.`
794- // we need to investigate this so that we can un-quarantine the Angular tests
795- quarantine : true ,
796787 } ,
797788 {
798789 name : "nuxt:workers" ,
Original file line number Diff line number Diff line change 11import { AngularAppEngine , createRequestHandler } from '@angular/ssr' ;
22
3- const angularApp = new AngularAppEngine ( ) ;
3+ const angularApp = new AngularAppEngine ( {
4+ // It is safe to set allow `localhost`, so that SSR can run in local development,
5+ // as, in production, Cloudflare will ensure that `localhost` is not the host.
6+ allowedHosts : [ 'localhost' ] ,
7+ } ) ;
48
59/**
610 * This is a request handler used by the Angular CLI (dev-server and during build).
Original file line number Diff line number Diff line change 11import { AngularAppEngine , createRequestHandler } from '@angular/ssr' ;
22
3- const angularApp = new AngularAppEngine ( ) ;
3+ const angularApp = new AngularAppEngine ( {
4+ // It is safe to set allow `localhost`, so that SSR can run in local development,
5+ // as, in production, Cloudflare will ensure that `localhost` is not the host.
6+ allowedHosts : [ 'localhost' ] ,
7+ } ) ;
48
59/**
610 * This is a request handler used by the Angular CLI (dev-server and during build).
Original file line number Diff line number Diff line change @@ -60,7 +60,11 @@ async function overrideServerFile() {
6060 dedent `
6161 import { AngularAppEngine, createRequestHandler } from '@angular/ssr';
6262
63- const angularApp = new AngularAppEngine();
63+ const angularApp = new AngularAppEngine({
64+ // It is safe to set allow \`localhost\`, so that SSR can run in local development,
65+ // as, in production, Cloudflare will ensure that \`localhost\` is not the host.
66+ allowedHosts: ['localhost'],
67+ });
6468
6569 /**
6670 * This is a request handler used by the Angular CLI (dev-server and during build).
You can’t perform that action at this time.
0 commit comments