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

fix x-forwarded-port header #63303

Merged
merged 5 commits into from
Mar 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix x-forwarded-port
Ethan-Arrowood committed Mar 14, 2024
commit cb3f0a5381e275f13bbc32a68c5ad62e9b8442bd
6 changes: 5 additions & 1 deletion packages/next/src/server/base-server.ts
Original file line number Diff line number Diff line change
@@ -889,7 +889,11 @@ export default abstract class Server<ServerOptions extends Options = Options> {
}

const { originalRequest } = req as NodeNextRequest
const isHttps = !!(originalRequest?.socket as TLSSocket)?.encrypted
const xForwardedProto = originalRequest?.headers['x-forwarded-proto']
const isHttps = xForwardedProto
? xForwardedProto === 'https'
: !!(originalRequest?.socket as TLSSocket)?.encrypted

req.headers['x-forwarded-host'] ??= req.headers['host'] ?? this.hostname
req.headers['x-forwarded-port'] ??= this.port
? this.port.toString()