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:
parent
3a144b1a69
commit
b731b3de73
3 changed files with 8 additions and 3 deletions
5
.changeset/plenty-carrots-nail.md
Normal file
5
.changeset/plenty-carrots-nail.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fixes a bug where a catchall route would match an image endpoint request
|
|
@ -13,7 +13,7 @@ export function injectImageEndpoint(
|
||||||
mode: 'dev' | 'build',
|
mode: 'dev' | 'build',
|
||||||
cwd?: string,
|
cwd?: string,
|
||||||
) {
|
) {
|
||||||
manifest.routes.push(getImageEndpointData(settings, mode, cwd));
|
manifest.routes.unshift(getImageEndpointData(settings, mode, cwd));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ensureImageEndpointRoute(
|
export function ensureImageEndpointRoute(
|
||||||
|
@ -22,8 +22,8 @@ export function ensureImageEndpointRoute(
|
||||||
mode: 'dev' | 'build',
|
mode: 'dev' | 'build',
|
||||||
cwd?: string,
|
cwd?: string,
|
||||||
) {
|
) {
|
||||||
if (!manifest.routes.some((route) => route.route === '/_image')) {
|
if (!manifest.routes.some((route) => route.route === settings.config.image.endpoint.route)) {
|
||||||
manifest.routes.push(getImageEndpointData(settings, mode, cwd));
|
manifest.routes.unshift(getImageEndpointData(settings, mode, cwd));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue