Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
ec62ea61
Unverified
Commit
ec62ea61
authored
Apr 12, 2021
by
JJ Kasper
Committed by
GitHub
Apr 12, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure minimal mode SSR 404 handling is correct (#23996)
parent
f02363e0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
829 additions
and
0 deletions
+829
-0
next-server.ts
packages/next/next-server/server/next-server.ts
+1
-0
config.js
test/integration/required-server-files-ssr-404/lib/config.js
+13
-0
next.config.js
.../integration/required-server-files-ssr-404/next.config.js
+12
-0
404.js
test/integration/required-server-files-ssr-404/pages/404.js
+3
-0
[slug].js
...integration/required-server-files-ssr-404/pages/[slug].js
+18
-0
_app.js
test/integration/required-server-files-ssr-404/pages/_app.js
+17
-0
[[...rest]].js
...ed-server-files-ssr-404/pages/api/optional/[[...rest]].js
+7
-0
[[...rest]].js
...uired-server-files-ssr-404/pages/catch-all/[[...rest]].js
+29
-0
[slug].js
...ion/required-server-files-ssr-404/pages/dynamic/[slug].js
+23
-0
gip.js
...gration/required-server-files-ssr-404/pages/errors/gip.js
+14
-0
[post].js
.../required-server-files-ssr-404/pages/errors/gsp/[post].js
+28
-0
gssp.js
...ration/required-server-files-ssr-404/pages/errors/gssp.js
+16
-0
[slug].js
...on/required-server-files-ssr-404/pages/fallback/[slug].js
+30
-0
index.js
.../integration/required-server-files-ssr-404/pages/index.js
+28
-0
[[...rest]].js
...ed-server-files-ssr-404/pages/optional-ssg/[[...rest]].js
+20
-0
[[...rest]].js
...ed-server-files-ssr-404/pages/optional-ssp/[[...rest]].js
+13
-0
index.test.js
...egration/required-server-files-ssr-404/test/index.test.js
+557
-0
No files found.
packages/next/next-server/server/next-server.ts
View file @
ec62ea61
...
...
@@ -1288,6 +1288,7 @@ export default class Server {
// we don't modify the URL for _next/data request but still
// call render so we special case this to prevent an infinite loop
if
(
!
this
.
minimalMode
&&
!
query
.
_nextDataReq
&&
(
url
.
match
(
/^
\/
_next
\/
/
)
||
(
this
.
hasStaticDir
&&
url
.
match
(
/^
\/
static
\/
/
)))
...
...
test/integration/required-server-files-ssr-404/lib/config.js
0 → 100644
View file @
ec62ea61
let
curConfig
const
idk
=
Math
.
random
()
export
default
()
=>
{
console
.
log
(
'returning config'
,
idk
,
curConfig
)
return
curConfig
}
export
function
setConfig
(
configValue
)
{
curConfig
=
configValue
console
.
log
(
'set config'
,
idk
,
configValue
)
}
test/integration/required-server-files-ssr-404/next.config.js
0 → 100644
View file @
ec62ea61
module
.
exports
=
{
// ensure incorrect target is overridden by env
target
:
'serverless'
,
rewrites
()
{
return
[
{
source
:
'/some-catch-all/:path*'
,
destination
:
'/'
,
},
]
},
}
test/integration/required-server-files-ssr-404/pages/404.js
0 → 100644
View file @
ec62ea61
export
default
function
NotFound
()
{
return
'custom 404'
}
test/integration/required-server-files-ssr-404/pages/[slug].js
0 → 100644
View file @
ec62ea61
export
const
getStaticProps
=
()
=>
{
return
{
props
:
{
hello
:
'world'
,
},
}
}
export
const
getStaticPaths
=
()
=>
{
return
{
paths
:
[],
fallback
:
true
,
}
}
export
default
function
Page
(
props
)
{
return
<
p
id
=
"slug-page"
>
[
slug
]
page
<
/p
>
}
test/integration/required-server-files-ssr-404/pages/_app.js
0 → 100644
View file @
ec62ea61
import
App
from
'next/app'
import
{
setConfig
}
from
'../lib/config'
setConfig
({
hello
:
'world'
})
function
MyApp
({
Component
,
pageProps
})
{
return
<
Component
{...
pageProps
}
/
>
}
MyApp
.
getInitialProps
=
async
(
appContext
)
=>
{
// calls page's `getInitialProps` and fills `appProps.pageProps`
const
appProps
=
await
App
.
getInitialProps
(
appContext
)
return
{
...
appProps
}
}
export
default
MyApp
test/integration/required-server-files-ssr-404/pages/api/optional/[[...rest]].js
0 → 100644
View file @
ec62ea61
export
default
(
req
,
res
)
=>
{
console
.
log
(
req
.
url
,
'query'
,
req
.
query
)
res
.
json
({
url
:
req
.
url
,
query
:
req
.
query
,
})
}
test/integration/required-server-files-ssr-404/pages/catch-all/[[...rest]].js
0 → 100644
View file @
ec62ea61
import
{
useRouter
}
from
'next/router'
export
const
getStaticProps
=
({
params
})
=>
{
return
{
props
:
{
hello
:
'world'
,
params
:
params
||
null
,
random
:
Math
.
random
(),
},
}
}
export
const
getStaticPaths
=
()
=>
{
return
{
paths
:
[
'/catch-all/hello'
],
fallback
:
true
,
}
}
export
default
function
Page
(
props
)
{
const
router
=
useRouter
()
return
(
<>
<
p
id
=
"catch-all"
>
optional
catch
-
all
page
<
/p
>
<
p
id
=
"router"
>
{
JSON
.
stringify
(
router
)}
<
/p
>
<
p
id
=
"props"
>
{
JSON
.
stringify
(
props
)}
<
/p
>
<
/
>
)
}
test/integration/required-server-files-ssr-404/pages/dynamic/[slug].js
0 → 100644
View file @
ec62ea61
import
{
useRouter
}
from
'next/router'
export
const
getServerSideProps
=
({
params
})
=>
{
return
{
props
:
{
hello
:
'world'
,
slug
:
params
.
slug
,
random
:
Math
.
random
(),
},
}
}
export
default
function
Page
(
props
)
{
const
router
=
useRouter
()
return
(
<>
<
p
id
=
"dynamic"
>
dynamic
page
<
/p
>
<
p
id
=
"slug"
>
{
props
.
slug
}
<
/p
>
<
p
id
=
"router"
>
{
JSON
.
stringify
(
router
)}
<
/p
>
<
p
id
=
"props"
>
{
JSON
.
stringify
(
props
)}
<
/p
>
<
/
>
)
}
test/integration/required-server-files-ssr-404/pages/errors/gip.js
0 → 100644
View file @
ec62ea61
function
Page
(
props
)
{
return
<
p
>
here
comes
an
error
<
/p
>
}
Page
.
getInitialProps
=
({
query
})
=>
{
if
(
query
.
crash
)
{
throw
new
Error
(
'gip hit an oops'
)
}
return
{
hello
:
'world'
,
}
}
export
default
Page
test/integration/required-server-files-ssr-404/pages/errors/gsp/[post].js
0 → 100644
View file @
ec62ea61
import
{
useRouter
}
from
'next/router'
function
Page
(
props
)
{
if
(
useRouter
().
isFallback
)
{
return
<
p
>
loading
...
<
/p
>
}
return
<
p
>
here
comes
an
error
<
/p
>
}
export
const
getStaticPaths
=
()
=>
{
return
{
paths
:
[],
fallback
:
true
,
}
}
export
const
getStaticProps
=
({
params
})
=>
{
if
(
params
.
post
===
'crash'
)
{
throw
new
Error
(
'gsp hit an oops'
)
}
return
{
props
:
{
hello
:
'world'
,
},
}
}
export
default
Page
test/integration/required-server-files-ssr-404/pages/errors/gssp.js
0 → 100644
View file @
ec62ea61
function
Page
(
props
)
{
return
<
p
>
here
comes
an
error
<
/p
>
}
export
const
getServerSideProps
=
({
query
})
=>
{
if
(
query
.
crash
)
{
throw
new
Error
(
'gssp hit an oops'
)
}
return
{
props
:
{
hello
:
'world'
,
},
}
}
export
default
Page
test/integration/required-server-files-ssr-404/pages/fallback/[slug].js
0 → 100644
View file @
ec62ea61
import
{
useRouter
}
from
'next/router'
export
const
getStaticProps
=
({
params
})
=>
{
return
{
props
:
{
hello
:
'world'
,
slug
:
params
.
slug
,
random
:
Math
.
random
(),
},
}
}
export
const
getStaticPaths
=
()
=>
{
return
{
paths
:
[
'/fallback/first'
],
fallback
:
true
,
}
}
export
default
function
Page
(
props
)
{
const
router
=
useRouter
()
return
(
<>
<
p
id
=
"fallback"
>
fallback
page
<
/p
>
<
p
id
=
"slug"
>
{
props
.
slug
}
<
/p
>
<
p
id
=
"router"
>
{
JSON
.
stringify
(
router
)}
<
/p
>
<
p
id
=
"props"
>
{
JSON
.
stringify
(
props
)}
<
/p
>
<
/
>
)
}
test/integration/required-server-files-ssr-404/pages/index.js
0 → 100644
View file @
ec62ea61
import
{
useRouter
}
from
'next/router'
import
getConfig
from
'../lib/config'
const
localConfig
=
getConfig
()
if
(
localConfig
.
hello
!==
'world'
)
{
throw
new
Error
(
'oof import order is wrong, _app comes first'
)
}
export
const
getServerSideProps
=
({
req
})
=>
{
return
{
props
:
{
hello
:
'world'
,
random
:
Math
.
random
(),
},
}
}
export
default
function
Page
(
props
)
{
const
router
=
useRouter
()
return
(
<>
<
p
id
=
"index"
>
index
page
<
/p
>
<
p
id
=
"router"
>
{
JSON
.
stringify
(
router
)}
<
/p
>
<
p
id
=
"props"
>
{
JSON
.
stringify
(
props
)}
<
/p
>
<
/
>
)
}
test/integration/required-server-files-ssr-404/pages/optional-ssg/[[...rest]].js
0 → 100644
View file @
ec62ea61
export
const
getStaticProps
=
({
params
})
=>
{
return
{
props
:
{
random
:
Math
.
random
(),
params
:
params
||
null
,
},
revalidate
:
1
,
}
}
export
const
getStaticPaths
=
()
=>
{
return
{
paths
:
[],
fallback
:
true
,
}
}
export
default
function
Page
(
props
)
{
return
<
p
id
=
"props"
>
{
JSON
.
stringify
(
props
)}
<
/p
>
}
test/integration/required-server-files-ssr-404/pages/optional-ssp/[[...rest]].js
0 → 100644
View file @
ec62ea61
export
const
getServerSideProps
=
({
query
,
params
})
=>
{
return
{
props
:
{
random
:
Math
.
random
(),
query
:
query
,
params
:
params
||
null
,
},
}
}
export
default
function
Page
(
props
)
{
return
<
p
id
=
"props"
>
{
JSON
.
stringify
(
props
)}
<
/p
>
}
test/integration/required-server-files-ssr-404/test/index.test.js
0 → 100644
View file @
ec62ea61
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment