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
dbd41725
Commit
dbd41725
authored
Mar 26, 2019
by
Luis Fernando Alvarez D
Committed by
Tim Neutkens
Mar 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed the X-Powered-By header (#6789)
Related to #6776
parent
affe356a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
0 additions
and
55 deletions
+0
-55
config.js
packages/next-server/server/config.js
+0
-1
next-server.ts
packages/next-server/server/next-server.ts
+0
-3
README.md
packages/next/README.md
+0
-11
index.test.js
test/integration/production/test/index.test.js
+0
-40
No files found.
packages/next-server/server/config.js
View file @
dbd41725
...
@@ -8,7 +8,6 @@ const defaultConfig = {
...
@@ -8,7 +8,6 @@ const defaultConfig = {
env
:
[],
env
:
[],
webpack
:
null
,
webpack
:
null
,
webpackDevMiddleware
:
null
,
webpackDevMiddleware
:
null
,
poweredByHeader
:
true
,
distDir
:
'.next'
,
distDir
:
'.next'
,
assetPrefix
:
''
,
assetPrefix
:
''
,
configOrigin
:
'default'
,
configOrigin
:
'default'
,
...
...
packages/next-server/server/next-server.ts
View file @
dbd41725
...
@@ -272,9 +272,6 @@ export default class Server {
...
@@ -272,9 +272,6 @@ export default class Server {
return
return
}
}
if
(
this
.
nextConfig
.
poweredByHeader
)
{
res
.
setHeader
(
'X-Powered-By'
,
'Next.js '
+
process
.
env
.
__NEXT_VERSION
)
}
return
this
.
sendHTML
(
req
,
res
,
html
)
return
this
.
sendHTML
(
req
,
res
,
html
)
}
}
...
...
packages/next/README.md
View file @
dbd41725
...
@@ -1450,17 +1450,6 @@ module.exports = {
...
@@ -1450,17 +1450,6 @@ module.exports = {
}
}
```
```
#### Disabling X-Powered-By
Next.js generates X-Powered-By response header with version information for every page. You can disable it with:
```
js
// next.config.js
module.exports = {
poweredByHeader: false
}
```
#### Configuring the onDemandEntries
#### Configuring the onDemandEntries
Next exposes some options that give you some control over how the server will dispose or keep in memories pages built:
Next exposes some options that give you some control over how the server will dispose or keep in memories pages built:
...
...
test/integration/production/test/index.test.js
View file @
dbd41725
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
import
{
readFileSync
}
from
'fs'
import
{
readFileSync
}
from
'fs'
import
{
join
}
from
'path'
import
{
join
}
from
'path'
import
{
import
{
pkg
,
nextServer
,
nextServer
,
runNextCommand
,
runNextCommand
,
startApp
,
startApp
,
...
@@ -310,45 +309,6 @@ describe('Production Usage', () => {
...
@@ -310,45 +309,6 @@ describe('Production Usage', () => {
})
})
})
})
describe
(
'X-Powered-By header'
,
()
=>
{
it
(
'should set it by default'
,
async
()
=>
{
const
req
=
{
url
:
'/stateless'
,
headers
:
{}
}
const
headers
=
{}
const
res
=
{
getHeader
(
key
)
{
return
headers
[
key
]
},
setHeader
(
key
,
value
)
{
headers
[
key
]
=
value
},
end
()
{}
}
await
app
.
render
(
req
,
res
,
req
.
url
)
expect
(
headers
[
'X-Powered-By'
]).
toEqual
(
`Next.js
${
pkg
.
version
}
`
)
})
it
(
'should not set it when poweredByHeader==false'
,
async
()
=>
{
const
req
=
{
url
:
'/stateless'
,
headers
:
{}
}
const
originalConfigValue
=
app
.
nextConfig
.
poweredByHeader
app
.
nextConfig
.
poweredByHeader
=
false
const
res
=
{
getHeader
()
{
return
false
},
setHeader
(
key
,
value
)
{
if
(
key
===
'XPoweredBy'
)
{
throw
new
Error
(
'Should not set the XPoweredBy header'
)
}
},
end
()
{}
}
await
app
.
render
(
req
,
res
,
req
.
url
)
app
.
nextConfig
.
poweredByHeader
=
originalConfigValue
})
})
it
(
'should not expose the compiled page file in development'
,
async
()
=>
{
it
(
'should not expose the compiled page file in development'
,
async
()
=>
{
const
url
=
`http://localhost:
${
appPort
}
`
const
url
=
`http://localhost:
${
appPort
}
`
await
fetch
(
`
${
url
}
/stateless`
)
// make sure the stateless page is built
await
fetch
(
`
${
url
}
/stateless`
)
// make sure the stateless page is built
...
...
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