File tree Expand file tree Collapse file tree
packages/start-server-core/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -349,18 +349,22 @@ async function handleServerRoutes({
349349 let url = new URL ( request . url )
350350 url = executeRewriteInput ( router . rewrite , url )
351351 const pathname = url . pathname
352+ // this will perform a fuzzy match, however for server routes we need an exact match
353+ // if the route is not an exact match, executeRouter will handle rendering the app router
354+ // the match will be cached internally, so no extra work is done during the app router render
352355 const { matchedRoutes, foundRoute, routeParams } =
353356 router . getMatchedRoutes ( pathname )
354357
358+ const isExactMatch = foundRoute && routeParams [ '**' ] === undefined
359+
355360 // TODO: Error handling? What happens when its `throw redirect()` vs `throw new Error()`?
356361
357362 const middlewares = flattenMiddlewares (
358363 matchedRoutes . flatMap ( ( r ) => r . options . server ?. middleware ) . filter ( Boolean ) ,
359364 ) . map ( ( d ) => d . options . server )
360365
361366 const server = foundRoute ?. options . server
362-
363- if ( server ) {
367+ if ( server && isExactMatch ) {
364368 if ( server . handlers ) {
365369 const handlers =
366370 typeof server . handlers === 'function'
You can’t perform that action at this time.
0 commit comments