You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run as a middleware using @fastify/middie, @astro/image integration fails to transform images (no matters which transformers is used) from HTTP/2 requests.
As a matter of fact, requests passed down to the Astro handler are properly routed to image endpoints, but local images can’t be loaded since hostname part of URLs are undefined (the loadRemoteImage() function receives https://undefined/... source URLs).
I am willing to submit a pull request for this issue.
The text was updated successfully, but these errors were encountered:
bmenant
changed the title
SSR Nodejs (middlware): HTTP2 requests ends have an undefined hostname
SSR Nodejs (middleware): HTTP2 requests have an undefined hostname
May 20, 2023
What version of
astro
are you using?2.5.0
Are you using an SSR adapter? If so, which one?
Node
What package manager are you using?
npm
What operating system are you using?
Linux
What browser are you using?
Firefox
Describe the Bug
Run as a middleware using @fastify/middie, @astro/image integration fails to transform images (no matters which transformers is used) from HTTP/2 requests.
As a matter of fact, requests passed down to the Astro handler are properly routed to image endpoints, but local images can’t be loaded since hostname part of URLs are
undefined
(theloadRemoteImage()
function receiveshttps://undefined/...
source URLs).The issue comes from the
createRequestFromNodeRequest()
function:https://github.com/withastro/astro/blob/main/packages/astro/src/core/app/node.ts#L17
HTTP2 Requests Headers from Fastify do not have the
host
property, but a:authority
pseudo header (see also https://nodejs.org/docs/latest-v18.x/api/http2.html#note-on-authority-and-host).How about using a fallback
req.headers.host || req.headers[':authority']
instead?I’ll push a merge request later.
Link to Minimal Reproducible Example
https://will.come.later/when/i/find/some/time
Participation
The text was updated successfully, but these errors were encountered: