-
Notifications
You must be signed in to change notification settings - Fork 365
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
fix: pass correct protocol to functions server #4604
Conversation
📊 Benchmark resultsComparing with b6d76e8 Package size: 286 MB(no change)
Legend
|
src/lib/functions/server.js
Outdated
const protocol = options.config.dev.https ? 'https' : 'http' | ||
const url = new URL(requestPath, `${protocol}://${request.get('host') || 'localhost'}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so the server doesn't listen on 80 anymore when you enable https?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have multiple servers running: a main server that then forwards requests to a functions server. The main server is listening on 443, the functions server is listening on 80.
This will continue to be the case, all we're changing is the event data that is sent to functions. Rather than using the protocol from the functions server (which will always be 80), we're using the protocol of the main server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but if you have two servers, you can't really use the config setting right?
since you need to set the protocol based on which server the request came in.
i'd recommend using a HTTP header for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only the main/outer server is exposed to customers. The functions server is an internal implementation detail. So the rawUrl
value of functions should always match the URL of the outer server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Summary
When using Netlify Dev with HTTPS, the
event.rawUrl
property in serverless functions incorrectly references the HTTP URL. This PR fixes that.Closes https://github.com/netlify/pod-compute/issues/86