0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-02-17 22:44:24 -05:00

fix: make image endpoint highest priority (#12591)

* fix: make image endpoint highest priority

* Use config for endpoint

* Add test
This commit is contained in:
Matt Kane 2024-12-03 10:51:34 +00:00 committed by GitHub
parent 3a144b1a69
commit b731b3de73
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 3 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fixes a bug where a catchall route would match an image endpoint request

View file

@ -13,7 +13,7 @@ export function injectImageEndpoint(
mode: 'dev' | 'build',
cwd?: string,
) {
manifest.routes.push(getImageEndpointData(settings, mode, cwd));
manifest.routes.unshift(getImageEndpointData(settings, mode, cwd));
}
export function ensureImageEndpointRoute(
@ -22,8 +22,8 @@ export function ensureImageEndpointRoute(
mode: 'dev' | 'build',
cwd?: string,
) {
if (!manifest.routes.some((route) => route.route === '/_image')) {
manifest.routes.push(getImageEndpointData(settings, mode, cwd));
if (!manifest.routes.some((route) => route.route === settings.config.image.endpoint.route)) {
manifest.routes.unshift(getImageEndpointData(settings, mode, cwd));
}
}