diff --git a/.changeset/friendly-pumpkins-reply.md b/.changeset/friendly-pumpkins-reply.md new file mode 100644 index 000000000000..0a6870e4744b --- /dev/null +++ b/.changeset/friendly-pumpkins-reply.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/adapter-vercel': patch +--- + +fix: move catch-all-regex to the end diff --git a/packages/adapter-vercel/index.js b/packages/adapter-vercel/index.js index b91edaa83127..6958975c27df 100644 --- a/packages/adapter-vercel/index.js +++ b/packages/adapter-vercel/index.js @@ -216,11 +216,6 @@ const plugin = function (defaults = {}) { /** @type {import('@sveltejs/kit').RouteDefinition[]} */ (group.routes) ); - if (singular) { - // Special case: One function for all routes - static_config.routes.push({ src: '/.*', dest: `/${name}` }); - } - for (const route of group.routes) { functions.set(route.pattern.toString(), name); } @@ -286,6 +281,12 @@ const plugin = function (defaults = {}) { } } + if (singular) { + // Common case: One function for all routes + // Needs to happen after ISR or else regex swallows all other matches + static_config.routes.push({ src: '/.*', dest: `/fn` }); + } + builder.log.minor('Copying assets...'); builder.writeClient(dirs.static);