@@ -21,7 +21,19 @@ function generateRegexFromPattern(pattern: string): string {
21
21
}
22
22
23
23
export function onBuildComplete ( ctx : OnBuildCompleteContext , frameworksAPIConfigArg : any ) {
24
- let frameworksAPIConfig : any = frameworksAPIConfigArg
24
+ const frameworksAPIConfig : any = frameworksAPIConfigArg ?? { }
25
+
26
+ // when migrating from @netlify /plugin-nextjs@4 image redirect to ipx might be cached in the browser
27
+ frameworksAPIConfig . redirects ??= [ ]
28
+ frameworksAPIConfig . redirects . push ( {
29
+ from : '/_ipx/*' ,
30
+ // w and q are too short to be used as params with id-length rule
31
+ // but we are forced to do so because of the next/image loader decides on their names
32
+ // eslint-disable-next-line id-length
33
+ query : { url : ':url' , w : ':width' , q : ':quality' } ,
34
+ to : '/.netlify/images?url=:url&w=:width&q=:quality' ,
35
+ status : 200 ,
36
+ } )
25
37
26
38
const { images } = ctx . config
27
39
if ( images . loader === 'custom' && images . loaderFile === NETLIFY_IMAGE_LOADER_FILE ) {
@@ -83,7 +95,6 @@ export function onBuildComplete(ctx: OnBuildCompleteContext, frameworksAPIConfig
83
95
84
96
if ( remoteImageSources . length !== 0 ) {
85
97
// https://docs.netlify.com/build/frameworks/frameworks-api/#images
86
- frameworksAPIConfig ??= { }
87
98
frameworksAPIConfig . images ??= { }
88
99
frameworksAPIConfig . images . remote_images = remoteImageSources
89
100
}
0 commit comments