Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/start-server-core/src/createStartHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,18 +349,22 @@ async function handleServerRoutes({
let url = new URL(request.url)
url = executeRewriteInput(router.rewrite, url)
const pathname = url.pathname
// this will perform a fuzzy match, however for server routes we need an exact match
// if the route is not an exact match, executeRouter will handle rendering the app router
// the match will be cached internally, so no extra work is done during the app router render
const { matchedRoutes, foundRoute, routeParams } =
router.getMatchedRoutes(pathname)

const isExactMatch = foundRoute && routeParams['**'] === undefined

// TODO: Error handling? What happens when its `throw redirect()` vs `throw new Error()`?

const middlewares = flattenMiddlewares(
matchedRoutes.flatMap((r) => r.options.server?.middleware).filter(Boolean),
).map((d) => d.options.server)

const server = foundRoute?.options.server

if (server) {
if (server && isExactMatch) {
if (server.handlers) {
const handlers =
typeof server.handlers === 'function'
Expand Down
Loading