-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom image path other then _image
does not work in dev
#8847
Comments
The code you linked is only ran in |
Yes, that is what I want to have. I want to have the same functionality implemented, that you have for the In the Astro documentation for local image services, you say, that you can use a custom image endpoint for transforming images. The example code is: getURL(options: ImageTransform, imageConfig: AstroConfig['image']) {
const searchParams = new URLSearchParams();
searchParams.append('href', typeof options.src === "string" ? options.src : options.src.src);
options.width && searchParams.append('w', options.width.toString());
options.height && searchParams.append('h', options.height.toString());
options.quality && searchParams.append('q', options.quality.toString());
options.format && searchParams.append('f', options.format);
return `/my_custom_endpoint_that_transforms_images?${searchParams}`; // <-- This one here will not work in dev mode as expected.
}, this would not work when running on a dev server. But it is documented as it would work in the same way as the |
Hmm, okay. This is quite a very niche usage, since typically people can just put their custom endpoint at The docs example is unfortunately outdated with our current recommendation, it was written before the existence of |
@Princesseuh, Thanks for looking into this issue. Wouldn’t it be possible, to have the image endpoint configurable? It might be a niche for now, but when more and more bigger projects go with astro, this might be a problem. From my experience with larger projects, they have often specific requirements. Or do you see astro more as a Framwork for smaller projects? |
Well, this is quite literally what we intend with Needing a custom image endpoint is already very niche (we have only a handful of users using that setting), but needing both a custom image endpoint AND a custom path for it is very very, very, very niche, ha. I think if we were to add the option, you'd be the only user using it at this time. We have quite large projects running in production right now that uses |
@Princesseuh, So It seems like we need to work with the |
I'm sorry for the inconvenience! An alternative for your project in the meantime could also be to patch the package using something like |
_image
does not work_image
does not work in dev
@Princesseuh, For now, we implemented a custom solution, that we aligned with your image implementation. For Dev and SSR we use the direct link to the image CDN and in Build mode we download the master images to the dist folder. I mean, in general a similar approach as you implemented. Thanks again for your support! |
In Astro 5 the route of the endpoint can now be customised using |
@Princesseuh, I already saw that. Really nice, thanks. |
Astro Info
If this issue only occurs in one browser, which browser is a problem?
no specific browser
Describe the Bug
When there is the need to implement a custom image endpoint, the hardcoded
_image
endpoint makes it not possible to create a custom endpoint for images. As inbuild
mode all query parameters are stripped away and only the ones on/_image
requests are allowed due to the hack, that is implemented:astro/packages/astro/src/vite-plugin-astro-server/request.ts
Line 50 in 3468c06
What's the expected result?
Due to our infrastructure, we need to have the images delivered through an endpoint that is like
/-/images
. When integrating a route like this with theinjectRoute
functionality of the Astro Integrations API, all query parameters will be stripped away.It would be nice, if the image endpoint can be customized via the astro config.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-gkz7uz-hszwyg
Participation
The text was updated successfully, but these errors were encountered: