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
e8c15e59
Unverified
Commit
e8c15e59
authored
Jan 24, 2022
by
JJ Kasper
Committed by
GitHub
Jan 24, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure fetch polyfill is loaded in next-server (#33616)
parent
9a2d97cc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
2 deletions
+11
-2
utils.ts
packages/next/build/utils.ts
+1
-0
next-server.ts
packages/next/server/next-server.ts
+1
-0
[[...rest]].js
...n/required-server-files/pages/api/optional/[[...rest]].js
+3
-1
[slug].js
...production/required-server-files/pages/fallback/[slug].js
+4
-1
gssp.js
test/production/required-server-files/pages/gssp.js
+2
-0
No files found.
packages/next/build/utils.ts
View file @
e8c15e59
import
'../server/node-polyfill-fetch'
import
chalk
from
'next/dist/compiled/chalk'
import
chalk
from
'next/dist/compiled/chalk'
import
getGzipSize
from
'next/dist/compiled/gzip-size'
import
getGzipSize
from
'next/dist/compiled/gzip-size'
import
textTable
from
'next/dist/compiled/text-table'
import
textTable
from
'next/dist/compiled/text-table'
...
...
packages/next/server/next-server.ts
View file @
e8c15e59
import
'./node-polyfill-fetch'
import
type
{
Params
,
Route
}
from
'./router'
import
type
{
Params
,
Route
}
from
'./router'
import
type
{
CacheFs
}
from
'../shared/lib/utils'
import
type
{
CacheFs
}
from
'../shared/lib/utils'
import
type
{
MiddlewareManifest
}
from
'../build/webpack/plugins/middleware-plugin'
import
type
{
MiddlewareManifest
}
from
'../build/webpack/plugins/middleware-plugin'
...
...
test/production/required-server-files/pages/api/optional/[[...rest]].js
View file @
e8c15e59
export
default
(
req
,
res
)
=>
{
export
default
async
(
req
,
res
)
=>
{
console
.
log
(
req
.
url
,
'query'
,
req
.
query
)
console
.
log
(
req
.
url
,
'query'
,
req
.
query
)
res
.
json
({
res
.
json
({
url
:
req
.
url
,
url
:
req
.
url
,
query
:
req
.
query
,
query
:
req
.
query
,
// make sure fetch if polyfilled
example
:
await
fetch
(
'https://example.com'
).
then
((
res
)
=>
res
.
text
()),
})
})
}
}
test/production/required-server-files/pages/fallback/[slug].js
View file @
e8c15e59
...
@@ -10,7 +10,10 @@ export const getStaticProps = ({ params }) => {
...
@@ -10,7 +10,10 @@ export const getStaticProps = ({ params }) => {
}
}
}
}
export
const
getStaticPaths
=
()
=>
{
export
const
getStaticPaths
=
async
()
=>
{
// make sure fetch if polyfilled
await
fetch
(
'https://example.com'
).
then
((
res
)
=>
res
.
text
())
return
{
return
{
paths
:
[
'/fallback/first'
],
paths
:
[
'/fallback/first'
],
fallback
:
true
,
fallback
:
true
,
...
...
test/production/required-server-files/pages/gssp.js
View file @
e8c15e59
...
@@ -19,6 +19,8 @@ export async function getServerSideProps({ res }) {
...
@@ -19,6 +19,8 @@ export async function getServerSideProps({ res }) {
props
:
{
props
:
{
hello
:
'world'
,
hello
:
'world'
,
data
,
data
,
// make sure fetch if polyfilled
example
:
await
fetch
(
'https://example.com'
).
then
((
res
)
=>
res
.
text
()),
},
},
}
}
}
}
...
...
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