mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
fix(astro:assets): inject /_image endpoint with prerendered=false on serverLikeOutput (#7423)
This commit is contained in:
parent
76fcdb84dd
commit
33cdc8622a
4 changed files with 9 additions and 3 deletions
5
.changeset/honest-flies-care.md
Normal file
5
.changeset/honest-flies-care.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Ensure injected `/_image` endpoint for image optimization is not prerendered on hybrid output.
|
|
@ -1293,6 +1293,7 @@ export type InjectedScriptStage = 'before-hydration' | 'head-inline' | 'page' |
|
|||
export interface InjectedRoute {
|
||||
pattern: string;
|
||||
entryPoint: string;
|
||||
prerender?: boolean;
|
||||
}
|
||||
export interface AstroConfig extends z.output<typeof AstroConfigSchema> {
|
||||
// Public:
|
||||
|
|
|
@ -24,7 +24,7 @@ export function createBaseSettings(config: AstroConfig): AstroSettings {
|
|||
adapter: undefined,
|
||||
injectedRoutes:
|
||||
config.experimental.assets && isServerLikeOutput(config)
|
||||
? [{ pattern: '/_image', entryPoint: 'astro/assets/image-endpoint' }]
|
||||
? [{ pattern: '/_image', entryPoint: 'astro/assets/image-endpoint', prerender: false }]
|
||||
: [],
|
||||
pageExtensions: ['.astro', '.html', ...SUPPORTED_MARKDOWN_FILE_EXTENSIONS],
|
||||
contentEntryTypes: [markdownContentEntryType],
|
||||
|
|
|
@ -387,7 +387,7 @@ export function createRouteManifest(
|
|||
comparator(injectedRouteToItem({ config, cwd }, a), injectedRouteToItem({ config, cwd }, b))
|
||||
)
|
||||
.reverse() // prepend to the routes array from lowest to highest priority
|
||||
.forEach(({ pattern: name, entryPoint }) => {
|
||||
.forEach(({ pattern: name, entryPoint, prerender: prerenderInjected }) => {
|
||||
let resolved: string;
|
||||
try {
|
||||
resolved = require.resolve(entryPoint, { paths: [cwd || fileURLToPath(config.root)] });
|
||||
|
@ -440,7 +440,7 @@ export function createRouteManifest(
|
|||
component,
|
||||
generate,
|
||||
pathname: pathname || void 0,
|
||||
prerender,
|
||||
prerender: prerenderInjected ?? prerender,
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue