fix(astro/core/app/node): support http2 requests (#7215)
This commit is contained in:
parent
fea3069360
commit
6e27f2f6db
2 changed files with 9 additions and 3 deletions
5
.changeset/curvy-pumpkins-remain.md
Normal file
5
.changeset/curvy-pumpkins-remain.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Node adapter fallbacks to `:authority` http2 pseudo-header when `host` is nullish.
|
|
@ -14,11 +14,12 @@ function createRequestFromNodeRequest(req: NodeIncomingMessage, body?: Uint8Arra
|
|||
req.socket instanceof TLSSocket || req.headers['x-forwarded-proto'] === 'https'
|
||||
? 'https'
|
||||
: 'http';
|
||||
let url = `${protocol}://${req.headers.host}${req.url}`;
|
||||
let rawHeaders = req.headers as Record<string, any>;
|
||||
const hostname = req.headers.host || req.headers[':authority'];
|
||||
const url = `${protocol}://${hostname}${req.url}`;
|
||||
const rawHeaders = req.headers as Record<string, any>;
|
||||
const entries = Object.entries(rawHeaders);
|
||||
const method = req.method || 'GET';
|
||||
let request = new Request(url, {
|
||||
const request = new Request(url, {
|
||||
method,
|
||||
headers: new Headers(entries),
|
||||
body: ['HEAD', 'GET'].includes(method) ? null : body,
|
||||
|
|
Loading…
Reference in a new issue