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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/msha/handlers/function.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.

},
onConnectionLost(req, res, target, "↳")
);
Expand Down