Skip to content

Commit

Permalink
yet another experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
javivelasco committed Jun 16, 2022
1 parent e56210e commit 0439b54
Showing 1 changed file with 6 additions and 26 deletions.
32 changes: 6 additions & 26 deletions packages/next/server/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,17 +314,19 @@ export default class Router {
continue
}

const requiresBasepathToMatch =
const usesBasepathOnMatch =
customRouteTypes.has(testRoute.type) ||
testRoute.name === 'middleware catchall' ||
testRoute.name === 'public folder catchall'

if (!requiresBasepathToMatch) {
pathnameInfo.basePath = ''
} else if (getRequestMeta(req, '_nextHadBasePath')) {
if (getRequestMeta(req, '_nextHadBasePath')) {
pathnameInfo.basePath = this.basePath
}

if (!usesBasepathOnMatch) {
pathnameInfo.basePath = ''
}

if (
customRouteTypes.has(testRoute.type) &&
!testRoute.internal &&
Expand All @@ -350,7 +352,6 @@ export default class Router {

if (testRoute.has && newParams) {
const hasParams = matchHas(req, testRoute.has, parsedUrlUpdated.query)

if (hasParams) {
Object.assign(newParams, hasParams)
} else {
Expand All @@ -360,27 +361,6 @@ export default class Router {

// Check if the match function matched
if (newParams) {
// since we require basePath be present for non-custom-routes we
// 404 here when we matched an fs route
if (
this.basePath &&
!requiresBasepathToMatch &&
!getRequestMeta(req, '_nextHadBasePath') &&
!getRequestMeta(req, '_nextDidRewrite')
) {
// 'page checker'
// 'dynamic route/page check'
// 'catchall public directory route'

// if (testRoute.requireBasePath !== false) {
// consider this a non-match so the 404 renders
// return false
// }
// page checker occurs before rewrites so we need to continue
// to check those since they don't always require basePath
continue
}

parsedUrlUpdated.pathname = formatNextPathnameInfo({
ignorePrefix: true,
...pathnameInfo,
Expand Down

0 comments on commit 0439b54

Please sign in to comment.