Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico authored and astrobot-houston committed Oct 9, 2024
1 parent e96bcae commit 116c533
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
7 changes: 4 additions & 3 deletions packages/astro/src/core/app/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ export class NodeApp extends App {

// @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 =
forwardedPort ?? req.socket?.remotePort?.toString() ?? (isEncrypted ? '443' : '80');

const portInHostname = typeof hostname === 'string' && /:\d+$/.test(hostname);
const hostnamePort = portInHostname ? hostname : `${hostname}:${port}`
const hostnamePort = portInHostname ? hostname : `${hostname}:${port}`;

const url = `${protocol}://${hostnamePort}${req.url}`;
const options: RequestInit = {
Expand All @@ -105,7 +106,7 @@ export class NodeApp extends App {
// @example "1.1.1.1,8.8.8.8" => "1.1.1.1"
const forwardedClientIp = getFirstForwardedValue(req.headers['x-forwarded-for']);
const clientIp = forwardedClientIp || req.socket?.remoteAddress;
if (clientIp) {
if (clientIp) {
Reflect.set(request, clientAddressSymbol, clientIp);
}

Expand Down
1 change: 0 additions & 1 deletion packages/astro/test/units/app/node.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ describe('NodeApp', () => {
assert.equal(result.url, 'https://example.com:3000/');
});


it('prefers port from x-forwarded-host', () => {
const result = NodeApp.createRequest({
...mockNodeRequest,
Expand Down

0 comments on commit 116c533

Please sign in to comment.