Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(start): set host header in proxied requests to match remote API hosts #578

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

danwatford
Copy link
Contributor

Changes the host header from localhost to the remote API host, permitting a host match to be found against the remote host's certificate.

Relates to #523

…hosts

Changes the host header from localhost to the remote API host, permitting a host match to be found against the remote host's certificate.
@@ -70,6 +70,8 @@ export function handleFunctionRequest(req: http.IncomingMessage, res: http.Serve
res,
{
target,
// Set the host header to match the remote API host.
changeOrigin: true,
Copy link
Member

Choose a reason for hiding this comment

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

Have you tried the local auth emulation with this option? I just want to make sure this option doesn't affect the cookies that are created locally. I don't think we set the domain in the cookie but just in case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I've not tested that case. If no one else if able to, I'll do so, but it will be a few days before I get a chance to work on swa-cli again.

Copy link
Contributor Author

@danwatford danwatford Oct 5, 2022

Choose a reason for hiding this comment

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

This has now been tested and found to be working correctly with the SWA CLI's authentication emulation. Test approach is described here - https://watfordconsulting.com/2022/10/05/access-the-azure-static-web-apps-clientprincipal/

Tested by running the auth-echo Azure Function both locally and remotely in a GitHub Codespace.

@davide-bergamini-sevenit

Please approve this, it's blocking for many. Thanks you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants