Skip to content

Commit bfdc7b0

Browse files
committed
fix(@angular/build): normalize allowedHosts in dev-server
This change ensures that allowed hosts starting with a dot (e.g. '.example.com') are converted to the wildcard format ('*.example.com') required by Angular SSR host validation. This aligns Vite's configuration style with Angular's internal validation logic.
1 parent b72f817 commit bfdc7b0

File tree

1 file changed

+3
-1
lines changed
  • packages/angular/build/src/builders/dev-server/vite

1 file changed

+3
-1
lines changed

packages/angular/build/src/builders/dev-server/vite/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ export async function* serveWithVite(
9797
browserOptions.ssr ||= true;
9898
}
9999

100+
// Vite allowedHost syntax doesn't allow `*.` but `.` acts as `*.`
101+
// Angular SSR supports `*.`.
100102
const allowedHosts = Array.isArray(serverOptions.allowedHosts)
101-
? [...serverOptions.allowedHosts]
103+
? serverOptions.allowedHosts.map((host) => (host[0] === '.' ? '*' + host : host))
102104
: [];
103105

104106
// Always allow the dev server host

0 commit comments

Comments
 (0)