Skip to content

Commit

Permalink
Ensure only appDir routes get new params behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed Jul 9, 2022
1 parent 6f9e6c9 commit 8864070
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
14 changes: 12 additions & 2 deletions packages/next/server/base-server.ts
Expand Up @@ -221,7 +221,8 @@ export default abstract class Server<ServerOptions extends Options = Options> {
protected abstract findPageComponents(
pathname: string,
query?: NextParsedUrlQuery,
params?: Params
params?: Params,
isAppDir?: boolean
): Promise<FindComponentsResult | null>
protected abstract getPagePath(pathname: string, locales?: string[]): string
protected abstract getFontManifest(): FontManifest | undefined
Expand Down Expand Up @@ -1795,11 +1796,20 @@ export default abstract class Server<ServerOptions extends Options = Options> {
if (typeof appPath === 'string') {
page = appPath
}

const result = await this.findPageComponents(
page,
query,
ctx.renderOpts.params
ctx.renderOpts.params,
typeof appPath === 'string'
)
console.log({
pathname,
appPath,
params: ctx.renderOpts.params,
query,
result,
})
if (result) {
try {
return await this.renderToResponseWithComponents(ctx, result)
Expand Down
5 changes: 3 additions & 2 deletions packages/next/server/dev/next-dev-server.ts
Expand Up @@ -1105,7 +1105,8 @@ export default class DevServer extends Server {
protected async findPageComponents(
pathname: string,
query: ParsedUrlQuery = {},
params: Params | null = null
params: Params | null = null,
isAppDir: boolean = false
): Promise<FindComponentsResult | null> {
await this.devReady
const compilationErr = await this.getCompilationError(pathname)
Expand All @@ -1124,7 +1125,7 @@ export default class DevServer extends Server {
this.serverComponentManifest = super.getServerComponentManifest()
}

return super.findPageComponents(pathname, query, params)
return super.findPageComponents(pathname, query, params, isAppDir)
} catch (err) {
if ((err as any).code !== 'ENOENT') {
throw err
Expand Down
7 changes: 5 additions & 2 deletions packages/next/server/next-server.ts
Expand Up @@ -683,7 +683,8 @@ export default class NextNodeServer extends BaseServer {
protected async findPageComponents(
pathname: string,
query: NextParsedUrlQuery = {},
params: Params | null = null
params: Params | null = null,
isAppDir: boolean = false
): Promise<FindComponentsResult | null> {
let paths = [
// try serving a static AMP version first
Expand Down Expand Up @@ -720,6 +721,8 @@ export default class NextNodeServer extends BaseServer {
continue
}

console.log({ pagePath, isAppDir })

return {
components,
query: {
Expand All @@ -733,7 +736,7 @@ export default class NextNodeServer extends BaseServer {
} as NextParsedUrlQuery)
: query),
// For appDir params is excluded.
...((this.nextConfig.experimental.appDir ? {} : params) || {}),
...((isAppDir ? {} : params) || {}),
},
}
} catch (err) {
Expand Down

0 comments on commit 8864070

Please sign in to comment.