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
5c6a20db
Commit
5c6a20db
authored
Jan 10, 2020
by
JJ Kasper
Committed by
Joe Haddad
Jan 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add refresh header for 308 redirect for IE11 compatibility (#10042)
parent
243c0382
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
9 deletions
+23
-9
next-server.ts
packages/next/next-server/server/next-server.ts
+15
-9
index.test.js
test/integration/custom-routes/test/index.test.js
+8
-0
No files found.
packages/next/next-server/server/next-server.ts
View file @
5c6a20db
...
@@ -485,17 +485,23 @@ export default class Server {
...
@@ -485,17 +485,23 @@ export default class Server {
if
(
route
.
type
===
'redirect'
)
{
if
(
route
.
type
===
'redirect'
)
{
const
parsedNewUrl
=
parseUrl
(
newUrl
)
const
parsedNewUrl
=
parseUrl
(
newUrl
)
res
.
setHeader
(
const
updatedDestination
=
formatUrl
({
'Location'
,
formatUrl
({
...
parsedDestination
,
...
parsedDestination
,
pathname
:
parsedNewUrl
.
pathname
,
pathname
:
parsedNewUrl
.
pathname
,
hash
:
parsedNewUrl
.
hash
,
hash
:
parsedNewUrl
.
hash
,
search
:
undefined
,
search
:
undefined
,
})
})
)
res
.
setHeader
(
'Location'
,
updatedDestination
)
res
.
statusCode
=
res
.
statusCode
=
(
route
as
Redirect
).
statusCode
||
DEFAULT_REDIRECT_STATUS
(
route
as
Redirect
).
statusCode
||
DEFAULT_REDIRECT_STATUS
// Since IE11 doesn't support the 308 header add backwards
// compatibility using refresh header
if
(
res
.
statusCode
===
308
)
{
res
.
setHeader
(
'Refresh'
,
`0;url=
${
updatedDestination
}
`
)
}
res
.
end
()
res
.
end
()
return
{
return
{
finished
:
true
,
finished
:
true
,
...
...
test/integration/custom-routes/test/index.test.js
View file @
5c6a20db
...
@@ -229,6 +229,14 @@ const runTests = (isDev = false) => {
...
@@ -229,6 +229,14 @@ const runTests = (isDev = false) => {
expect
(
res
.
headers
.
get
(
'x-second-header'
)).
toBe
(
'second'
)
expect
(
res
.
headers
.
get
(
'x-second-header'
)).
toBe
(
'second'
)
})
})
it
(
'should add refresh header for 308 redirect'
,
async
()
=>
{
const
res
=
await
fetchViaHTTP
(
appPort
,
'/redirect4'
,
undefined
,
{
redirect
:
'manual'
,
})
expect
(
res
.
status
).
toBe
(
308
)
expect
(
res
.
headers
.
get
(
'refresh'
)).
toBe
(
`0;url=/`
)
})
if
(
!
isDev
)
{
if
(
!
isDev
)
{
it
(
'should output routes-manifest successfully'
,
async
()
=>
{
it
(
'should output routes-manifest successfully'
,
async
()
=>
{
const
manifest
=
await
fs
.
readJSON
(
const
manifest
=
await
fs
.
readJSON
(
...
...
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