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'
|
req.socket instanceof TLSSocket || req.headers['x-forwarded-proto'] === 'https'
|
||||||
? 'https'
|
? 'https'
|
||||||
: 'http';
|
: 'http';
|
||||||
let url = `${protocol}://${req.headers.host}${req.url}`;
|
const hostname = req.headers.host || req.headers[':authority'];
|
||||||
let rawHeaders = req.headers as Record<string, any>;
|
const url = `${protocol}://${hostname}${req.url}`;
|
||||||
|
const rawHeaders = req.headers as Record<string, any>;
|
||||||
const entries = Object.entries(rawHeaders);
|
const entries = Object.entries(rawHeaders);
|
||||||
const method = req.method || 'GET';
|
const method = req.method || 'GET';
|
||||||
let request = new Request(url, {
|
const request = new Request(url, {
|
||||||
method,
|
method,
|
||||||
headers: new Headers(entries),
|
headers: new Headers(entries),
|
||||||
body: ['HEAD', 'GET'].includes(method) ? null : body,
|
body: ['HEAD', 'GET'].includes(method) ? null : body,
|
||||||
|
|
Loading…
Reference in a new issue