Skip to content

Commit

Permalink
use correct extra config for pages router
Browse files Browse the repository at this point in the history
  • Loading branch information
ecklf committed Aug 30, 2023
1 parent f567aaf commit bf87c06
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
11 changes: 6 additions & 5 deletions packages/next/src/build/analysis/get-page-static-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type { RSCMeta } from '../webpack/loaders/get-module-build-info'

// TODO: migrate preferredRegion here
// Don't forget to update the next-types-plugin file as well
const AUTHORIZED_EXTRA_PROPS = ['maxDuration']
const AUTHORIZED_EXTRA_APP_ROUTER_PROPS = ['maxDuration']

export interface MiddlewareConfig {
matchers?: MiddlewareMatcher[]
Expand Down Expand Up @@ -510,12 +510,11 @@ export async function getPageStaticInfo(params: {
}

let extraConfig: Record<string, any> | undefined
extraConfig = {}

if (extraProperties) {
extraConfig = {}

if (extraProperties && pageType === 'app') {
for (const prop of extraProperties) {
if (!AUTHORIZED_EXTRA_PROPS.includes(prop)) continue
if (!AUTHORIZED_EXTRA_APP_ROUTER_PROPS.includes(prop)) continue
try {
extraConfig[prop] = extractExportedConstValue(swcAST, prop)
} catch (e) {
Expand All @@ -524,6 +523,8 @@ export async function getPageStaticInfo(params: {
}
}
}
} else if (pageType === 'pages') {
extraConfig = { ...config }
}

if (pageType === 'app') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ export default function Page({ data }) {
;<p>hello {data}</p>
}

export const maxDuration = 3
export const config = {
maxDuration: 3,
}

export async function getServerSideProps() {
return { props: { data: 'world' } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ export default function Page() {
;<p>hello world</p>
}

export const maxDuration = 2
export const config = {
maxDuration: 2,
}

0 comments on commit bf87c06

Please sign in to comment.