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
89b2dfc5
Unverified
Commit
89b2dfc5
authored
Feb 03, 2020
by
JJ Kasper
Committed by
GitHub
Feb 03, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure runtime config works in dev mode for serverless targ… (#10402)
parent
c480c37c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
24 deletions
+45
-24
next-server.ts
packages/next/next-server/server/next-server.ts
+4
-6
index.test.js
...integration/serverless-runtime-configs/test/index.test.js
+41
-18
No files found.
packages/next/next-server/server/next-server.ts
View file @
89b2dfc5
...
@@ -163,12 +163,10 @@ export default class Server {
...
@@ -163,12 +163,10 @@ export default class Server {
}
}
// Initialize next/config with the environment configuration
// Initialize next/config with the environment configuration
if
(
this
.
nextConfig
.
target
===
'server'
)
{
envConfig
.
setConfig
({
envConfig
.
setConfig
({
serverRuntimeConfig
,
serverRuntimeConfig
,
publicRuntimeConfig
,
publicRuntimeConfig
,
})
})
}
this
.
serverBuildDir
=
join
(
this
.
serverBuildDir
=
join
(
this
.
distDir
,
this
.
distDir
,
...
...
test/integration/serverless-runtime-configs/test/index.test.js
View file @
89b2dfc5
...
@@ -6,6 +6,7 @@ import {
...
@@ -6,6 +6,7 @@ import {
nextBuild
,
nextBuild
,
findPort
,
findPort
,
killApp
,
killApp
,
launchApp
,
renderViaHTTP
,
renderViaHTTP
,
initNextServerScript
,
initNextServerScript
,
}
from
'next-test-utils'
}
from
'next-test-utils'
...
@@ -74,24 +75,7 @@ describe('Serverless runtime configs', () => {
...
@@ -74,24 +75,7 @@ describe('Serverless runtime configs', () => {
)
)
})
})
it
(
'should support runtime configs in serverless mode'
,
async
()
=>
{
const
testRuntimeConfig
=
async
(
app
,
appPort
)
=>
{
await
fs
.
writeFile
(
nextConfigPath
,
`module.exports = {
target: 'serverless',
serverRuntimeConfig: {
hello: 'world'
},
publicRuntimeConfig: {
another: 'thing'
}
}`
)
await
nextBuild
(
appDir
,
[],
{
stderr
:
true
,
stdout
:
true
})
const
appPort
=
await
findPort
()
const
app
=
await
nextStart
(
appDir
,
appPort
)
const
browser
=
await
webdriver
(
appPort
,
'/config'
)
const
browser
=
await
webdriver
(
appPort
,
'/config'
)
const
clientHTML
=
await
browser
.
eval
(
`document.documentElement.innerHTML`
)
const
clientHTML
=
await
browser
.
eval
(
`document.documentElement.innerHTML`
)
...
@@ -140,5 +124,44 @@ describe('Serverless runtime configs', () => {
...
@@ -140,5 +124,44 @@ describe('Serverless runtime configs', () => {
expect
(
JSON
.
parse
(
docClientConfig
)).
toEqual
(
expectedSsrConfig
)
expect
(
JSON
.
parse
(
docClientConfig
)).
toEqual
(
expectedSsrConfig
)
expect
(
JSON
.
parse
(
apiJson
)).
toEqual
(
expectedSsrConfig
)
expect
(
JSON
.
parse
(
apiJson
)).
toEqual
(
expectedSsrConfig
)
}
it
(
'should support runtime configs in serverless mode (production)'
,
async
()
=>
{
await
fs
.
writeFile
(
nextConfigPath
,
`module.exports = {
target: 'serverless',
serverRuntimeConfig: {
hello: 'world'
},
publicRuntimeConfig: {
another: 'thing'
}
}`
)
await
nextBuild
(
appDir
,
[],
{
stderr
:
true
,
stdout
:
true
})
const
appPort
=
await
findPort
()
const
app
=
await
nextStart
(
appDir
,
appPort
)
await
testRuntimeConfig
(
app
,
appPort
)
})
it
(
'should support runtime configs in serverless mode (dev)'
,
async
()
=>
{
await
fs
.
writeFile
(
nextConfigPath
,
`module.exports = {
target: 'serverless',
serverRuntimeConfig: {
hello: 'world'
},
publicRuntimeConfig: {
another: 'thing'
}
}`
)
const
appPort
=
await
findPort
()
const
app
=
await
launchApp
(
appDir
,
appPort
)
await
testRuntimeConfig
(
app
,
appPort
)
})
})
})
})
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