@@ -24,6 +24,7 @@ const writeEdgeManifest = async (ctx: PluginContext, manifest: NetlifyManifest)
2424}
2525
2626const writeHandlerFile = async ( ctx : PluginContext , { matchers, name } : NextDefinition ) => {
27+ const nextConfig = await ctx . getBuildConfig ( )
2728 const handlerName = getHandlerName ( { name } )
2829 const handlerDirectory = join ( ctx . edgeFunctionsDir , handlerName )
2930 const handlerRuntimeDirectory = join ( handlerDirectory , 'edge-runtime' )
@@ -38,6 +39,20 @@ const writeHandlerFile = async (ctx: PluginContext, { matchers, name }: NextDefi
3839 // read this file from the function at runtime.
3940 await writeFile ( join ( handlerRuntimeDirectory , 'matchers.json' ) , JSON . stringify ( matchers ) )
4041
42+ // The config is needed by the edge function to match and normalize URLs. To
43+ // avoid shipping and parsing a large file at runtime, let's strip it down to
44+ // just the properties that the edge function actually needs.
45+ const minimalNextConfig = {
46+ basePath : nextConfig . basePath ,
47+ i18n : nextConfig . i18n ,
48+ trailingSlash : nextConfig . trailingSlash ,
49+ }
50+
51+ await writeFile (
52+ join ( handlerRuntimeDirectory , 'next.config.json' ) ,
53+ JSON . stringify ( minimalNextConfig ) ,
54+ )
55+
4156 // Writing the function entry file. It wraps the middleware code with the
4257 // compatibility layer mentioned above.
4358 await writeFile (
0 commit comments