Fix Codespaces host rejection in Angular SSR host check#17
Merged
Conversation
@angular/ssr's isHostAllowed only treats an allowedHosts entry as a wildcard when it starts with '*.', so the previous '.app.github.dev' entry was ignored and the forwarded Codespaces host was rejected with 'Header "x-forwarded-host" ... is not allowed'. - Use '*.app.github.dev' (the form @angular/ssr matches) in the build target's security.allowedHosts. - Add allowedHosts to the serve target too, since 'ng serve' validates against the dev-server's list (not the build security list).
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.
Problem
Running the client in Codespaces still fails with:
Root cause
@angular/ssr'sisHostAllowedonly treats anallowedHostsentry as a wildcard when it starts with*.:The existing entry
.app.github.dev(leading dot) is therefore ignored, and the forwarded Codespaces host is rejected. Also,ng serve(what Codespaces runs) validates against the serve target'sallowedHosts, not the build target'ssecurity.allowedHosts, which had no entry at all.Fix
build.security.allowedHosts:.app.github.dev→*.app.github.dev.serve.options.allowedHosts: add*.app.github.dev.Verification
ng buildsucceeds;angular.jsonis valid.@angular/ssr's matcher:*.app.github.devallows…-4200.app.github.devandlocalhost, and rejects unrelated hosts.