#/_image url still used after running `build` in server mode with CDN

18 messages · Page 1 of 1 (latest)

sterile jolt
#

Hello,

I recently switched my setup to output: "server" (with the node adapter) and noticed that after build the images are still fetched with the url something like /_image?href=<CDN-url-here> which breaks all images. All images are imported using the Image or Picture component (within .astro or .mdx files).

Is this expected?

spare pebble
#

That is on purpose, do you get an error message or something when visiting the image?

sterile jolt
#

yes, it 404-es

spare pebble
#

What does "CDN-url-here" looks like?

sterile jolt
#

this is what the whole picture tag looks like

#

I have to mention that this works perfectly fine with SSG

#

same picture tag with SSG

sterile jolt
#

@spare pebble is this supposed to happen?

spare pebble
#

How are you building those links? Is it asset prefix?

sterile jolt
#

yes, I have assetPrefix set up in astro.config

spare pebble
#

There's not many people using that option, so perhaps there's a bug there. Is there a reproduction I could check out?

sterile jolt
#

I'll try to create a repro tomorrow

sterile jolt
#

hey, I found a fix for this. If you use SSR + CDN you must add remotePatterns / domains in the astro config file. I think this is missing from the docs.

bright fractal
sterile jolt
#

it is mentioned, but not as a requirement. It would be great if the text could be reworked a bit to inform that using a CDN is tightly coupled with this in a SSR setup

spare pebble
#

It normally should work either way, just you wouldn't get image processing if you didn't do it (the image would be shown as-is, since the domain is unauthorized)