mirror of
https://github.com/withastro/astro.git
synced 2024-12-30 22:03:56 -05:00
fix: revert regression of port computation (#12197)
* fix: revert regression of port computation * revert tests failing * address feedback * revert logic to how it was before
This commit is contained in:
parent
b0493596dc
commit
2aa2dfd05d
2 changed files with 9 additions and 5 deletions
5
.changeset/tidy-dancers-act.md
Normal file
5
.changeset/tidy-dancers-act.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fix a regression where a port was incorrectly added to the `Astro.url`
|
|
@ -83,12 +83,11 @@ export class NodeApp extends App {
|
|||
const hostname = forwardedHostname ?? req.headers.host ?? req.headers[':authority'];
|
||||
|
||||
// @example "443,8080,80" => "443"
|
||||
const forwardedPort = getFirstForwardedValue(req.headers['x-forwarded-port']);
|
||||
const port =
|
||||
forwardedPort ?? req.socket?.remotePort?.toString() ?? (isEncrypted ? '443' : '80');
|
||||
const port = getFirstForwardedValue(req.headers['x-forwarded-port']);
|
||||
|
||||
const portInHostname = typeof hostname === 'string' && /:\d+$/.test(hostname);
|
||||
const hostnamePort = portInHostname ? hostname : `${hostname}:${port}`;
|
||||
const hostnamePort = portInHostname ? hostname : `${hostname}${port ? `:${port}` : ''}`;
|
||||
|
||||
|
||||
const url = `${protocol}://${hostnamePort}${req.url}`;
|
||||
const options: RequestInit = {
|
||||
|
|
Loading…
Reference in a new issue