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
869bf0f1
Commit
869bf0f1
authored
Aug 11, 2019
by
Lukáš Huvar
Committed by
Tim Neutkens
Aug 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove 405 from render method (#8323)
* Revert 405 on pages * Modify tests
parent
5b115035
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
16 deletions
+4
-16
next-server.ts
packages/next-server/server/next-server.ts
+0
-12
index.test.js
test/integration/api-support/test/index.test.js
+2
-2
index.test.js
test/integration/production/test/index.test.js
+2
-2
No files found.
packages/next-server/server/next-server.ts
View file @
869bf0f1
...
@@ -524,12 +524,6 @@ export default class Server {
...
@@ -524,12 +524,6 @@ export default class Server {
return
this
.
findPageComponents
(
pathname
,
query
)
return
this
.
findPageComponents
(
pathname
,
query
)
.
then
(
.
then
(
result
=>
{
result
=>
{
if
(
!
(
req
.
method
===
'GET'
||
req
.
method
===
'HEAD'
))
{
res
.
statusCode
=
405
res
.
setHeader
(
'Allow'
,
[
'GET'
,
'HEAD'
])
return
this
.
renderError
(
null
,
req
,
res
,
pathname
,
query
)
}
return
this
.
renderToHTMLWithComponents
(
return
this
.
renderToHTMLWithComponents
(
req
,
req
,
res
,
res
,
...
@@ -552,12 +546,6 @@ export default class Server {
...
@@ -552,12 +546,6 @@ export default class Server {
return
this
.
findPageComponents
(
dynamicRoute
.
page
,
query
).
then
(
return
this
.
findPageComponents
(
dynamicRoute
.
page
,
query
).
then
(
result
=>
{
result
=>
{
if
(
!
(
req
.
method
===
'GET'
||
req
.
method
===
'HEAD'
))
{
res
.
statusCode
=
405
res
.
setHeader
(
'Allow'
,
[
'GET'
,
'HEAD'
])
return
this
.
renderError
(
null
,
req
,
res
,
pathname
,
query
)
}
return
this
.
renderToHTMLWithComponents
(
return
this
.
renderToHTMLWithComponents
(
req
,
req
,
res
,
res
,
...
...
test/integration/api-support/test/index.test.js
View file @
869bf0f1
...
@@ -197,12 +197,12 @@ function runTests (serverless = false) {
...
@@ -197,12 +197,12 @@ function runTests (serverless = false) {
expect
(
data
).
toEqual
({
nextjs
:
'cool'
})
expect
(
data
).
toEqual
({
nextjs
:
'cool'
})
})
})
it
(
'should return
405
on POST on pages'
,
async
()
=>
{
it
(
'should return
200
on POST on pages'
,
async
()
=>
{
const
res
=
await
fetchViaHTTP
(
appPort
,
'/user'
,
null
,
{
const
res
=
await
fetchViaHTTP
(
appPort
,
'/user'
,
null
,
{
method
:
'POST'
method
:
'POST'
})
})
expect
(
res
.
status
).
toEqual
(
405
)
expect
(
res
.
status
).
toEqual
(
200
)
})
})
it
(
'should return JSON on post on API'
,
async
()
=>
{
it
(
'should return JSON on post on API'
,
async
()
=>
{
...
...
test/integration/production/test/index.test.js
View file @
869bf0f1
...
@@ -80,11 +80,11 @@ describe('Production Usage', () => {
...
@@ -80,11 +80,11 @@ describe('Production Usage', () => {
expect
(
res
.
status
).
toBe
(
404
)
expect
(
res
.
status
).
toBe
(
404
)
})
})
it
(
'should render
405
for POST on page'
,
async
()
=>
{
it
(
'should render
200
for POST on page'
,
async
()
=>
{
const
res
=
await
fetch
(
`http://localhost:
${
appPort
}
/about`
,
{
const
res
=
await
fetch
(
`http://localhost:
${
appPort
}
/about`
,
{
method
:
'POST'
method
:
'POST'
})
})
expect
(
res
.
status
).
toBe
(
405
)
expect
(
res
.
status
).
toBe
(
200
)
})
})
it
(
'should render 404 for POST on missing page'
,
async
()
=>
{
it
(
'should render 404 for POST on missing page'
,
async
()
=>
{
...
...
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