Skip to content

Commit 1c333ae

Browse files
committed
Update 404 SSG check
1 parent ee9c1cd commit 1c333ae

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/next/next-server/server/next-server.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,13 +1183,13 @@ export default class Server {
11831183
{ components, query }: FindComponentsResult,
11841184
opts: RenderOptsPartial
11851185
): Promise<string | null> {
1186+
const is404Page = pathname === '/404'
1187+
11861188
// we need to ensure the status code if /404 is visited directly
1187-
if (pathname === '/404') {
1189+
if (is404Page) {
11881190
res.statusCode = 404
11891191
}
11901192

1191-
const isErrorPage = pathname === '/404' || pathname === '/_error'
1192-
11931193
// handle static page
11941194
if (typeof components.Component === 'string') {
11951195
return components.Component
@@ -1264,7 +1264,7 @@ export default class Server {
12641264
query.amp ? '.amp' : ''
12651265
}`
12661266

1267-
if (isErrorPage) {
1267+
if (is404Page && isSSG) {
12681268
ssgCacheKey = `${locale ? `/${locale}` : ''}${pathname}${
12691269
query.amp ? '.amp' : ''
12701270
}`
@@ -1315,7 +1315,7 @@ export default class Server {
13151315

13161316
// If we're here, that means data is missing or it's stale.
13171317
const maybeCoalesceInvoke = ssgCacheKey
1318-
? (fn: any) => withCoalescedInvoke(fn).bind(null, ssgCacheKey, [])
1318+
? (fn: any) => withCoalescedInvoke(fn).bind(null, ssgCacheKey!, [])
13191319
: (fn: any) => async () => {
13201320
const value = await fn()
13211321
return { isOrigin: true, value }

0 commit comments

Comments
 (0)