diff options
author | 2024-05-03 21:01:25 +0200 | |
---|---|---|
committer | 2024-05-03 15:01:25 -0400 | |
commit | 0c8da00eba0d2f7600063ae07fb90a55ddb5d567 (patch) | |
tree | 46d0b6db173779559705f07e09a67704b13608c1 /packages/integrations/node/test/url.test.js | |
parent | 891610e66b87b51829207179e6609cb72d511aa1 (diff) | |
download | astro-0c8da00eba0d2f7600063ae07fb90a55ddb5d567.tar.gz astro-0c8da00eba0d2f7600063ae07fb90a55ddb5d567.tar.zst astro-0c8da00eba0d2f7600063ae07fb90a55ddb5d567.zip |
fix: don't include port twice from x-forwarded-host and x-forwarded-port headers (#10917)
* fix: don't include port twice from x-forwarded-host and x-forwarded-port headers
* add changeset
* add test for port both in forwarded host and forwarded port
* don't include port if undefined
* Update .changeset/forty-wolves-turn.md
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
---------
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
Diffstat (limited to 'packages/integrations/node/test/url.test.js')
-rw-r--r-- | packages/integrations/node/test/url.test.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/packages/integrations/node/test/url.test.js b/packages/integrations/node/test/url.test.js index 6fc008236..77ca45836 100644 --- a/packages/integrations/node/test/url.test.js +++ b/packages/integrations/node/test/url.test.js @@ -92,4 +92,24 @@ describe('URL', () => { assert.equal($('body').text(), 'https://abc.xyz:444/'); }); + + it('accepts port in forwarded host and forwarded port', async () => { + const { handler } = await import('./fixtures/url/dist/server/entry.mjs'); + let { req, res, text } = createRequestAndResponse({ + headers: { + 'X-Forwarded-Proto': 'https', + 'X-Forwarded-Host': 'abc.xyz:444', + 'X-Forwarded-Port': '444', + }, + url: '/', + }); + + handler(req, res); + req.send(); + + const html = await text(); + const $ = cheerio.load(html); + + assert.equal($('body').text(), 'https://abc.xyz:444/'); + }); }); |