Skip to content

Commit

Permalink
fix(astro/core/app/node): support http2 requests (#7215)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmenant committed Jun 2, 2023
1 parent fea3069 commit 6e27f2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/curvy-pumpkins-remain.md
@@ -0,0 +1,5 @@
---
'astro': patch
---

Node adapter fallbacks to `:authority` http2 pseudo-header when `host` is nullish.
7 changes: 4 additions & 3 deletions packages/astro/src/core/app/node.ts
Expand Up @@ -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,
Expand Down

0 comments on commit 6e27f2f

Please sign in to comment.