Skip to content

Commit

Permalink
fix intercepted segments basepath option
Browse files Browse the repository at this point in the history
  • Loading branch information
vordgi committed Jan 10, 2024
1 parent 60c0720 commit c6b0ff8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
4 changes: 3 additions & 1 deletion packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,9 @@ export default async function build(

const appPaths = Array.from(appPageKeys)
// Interception routes are modelled as beforeFiles rewrites
rewrites.beforeFiles.push(...generateInterceptionRoutesRewrites(appPaths))
rewrites.beforeFiles.push(
...generateInterceptionRoutesRewrites(appPaths, config.basePath)
)

const totalAppPagesCount = appPaths.length

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ function voidParamsBeforeInterceptionMarker(path: string): string {
}

export function generateInterceptionRoutesRewrites(
appPaths: string[]
appPaths: string[],
basePath = ''
): Rewrite[] {
const rewrites: Rewrite[] = []

Expand All @@ -70,8 +71,8 @@ export function generateInterceptionRoutesRewrites(
.slice(2, -3)

rewrites.push({
source: normalizedInterceptedRoute,
destination: normalizedAppPath,
source: `${basePath}${normalizedInterceptedRoute}`,
destination: `${basePath}${normalizedAppPath}`,
has: [
{
type: 'header',
Expand Down
16 changes: 9 additions & 7 deletions packages/next/src/server/lib/router-utils/setup-dev-bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2270,13 +2270,15 @@ async function startWatcher(opts: SetupOpts) {
: undefined

opts.fsChecker.interceptionRoutes =
generateInterceptionRoutesRewrites(Object.keys(appPaths))?.map((item) =>
buildCustomRoute(
'before_files_rewrite',
item,
opts.nextConfig.basePath,
opts.nextConfig.experimental.caseSensitiveRoutes
)
generateInterceptionRoutesRewrites(Object.keys(appPaths))?.map(
(item) =>
buildCustomRoute(
'before_files_rewrite',
item,
opts.nextConfig.basePath,
opts.nextConfig.experimental.caseSensitiveRoutes
),
opts.nextConfig.basePath
) || []

const exportPathMap =
Expand Down

0 comments on commit c6b0ff8

Please sign in to comment.