@@ -379,6 +379,31 @@ const plugin = function (defaults = {}) {
379379 ) ;
380380 }
381381
382+ if ( builder . config . kit . experimental . remoteFunctions ) {
383+ // Ensure remote functions are always handled by the catchall route, which will be symlinked to /_app/remote.
384+ // This stops them from being affected by ISR config from other routes that match /[...rest] (ref: #15085)
385+ // and also makes them show as handled by `/_app/remote` in Vercel's observability.
386+
387+ const app_path = builder . getAppPath ( ) ;
388+ const remote_dir = path . join ( dirs . functions , app_path , 'remote' ) ; // Usually .vercel/output/functions/_app/remote
389+ const remote_symlink_path = `${ remote_dir } .func` ;
390+
391+ // Handle remote functions with the catchall route as it won't have any ISR settings
392+ const target = path . join ( dirs . functions , INTERNAL , 'catchall.func' ) ;
393+
394+ // Ensure the parent directory exists before symlinking
395+ builder . mkdirp ( path . join ( dirs . functions , app_path ) ) ;
396+
397+ const relative = path . relative ( path . dirname ( remote_symlink_path ) , target ) ;
398+
399+ fs . symlinkSync ( relative , remote_symlink_path ) ;
400+
401+ static_config . routes . push ( {
402+ src : `/${ app_path } /remote/.+` ,
403+ dest : `/${ app_path } /remote` // Maps to /![-]/catchall via the symlink
404+ } ) ;
405+ }
406+
382407 for ( const route of builder . routes ) {
383408 if ( is_prerendered ( route ) ) continue ;
384409
0 commit comments