Skip to content

Commit 869bf0f

Browse files
huv1ktimneutkens
authored andcommitted
Remove 405 from render method (vercel#8323)
* Revert 405 on pages * Modify tests
1 parent 5b11503 commit 869bf0f

File tree

3 files changed

+4
-16
lines changed

3 files changed

+4
-16
lines changed

packages/next-server/server/next-server.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -524,12 +524,6 @@ export default class Server {
524524
return this.findPageComponents(pathname, query)
525525
.then(
526526
result => {
527-
if (!(req.method === 'GET' || req.method === 'HEAD')) {
528-
res.statusCode = 405
529-
res.setHeader('Allow', ['GET', 'HEAD'])
530-
return this.renderError(null, req, res, pathname, query)
531-
}
532-
533527
return this.renderToHTMLWithComponents(
534528
req,
535529
res,
@@ -552,12 +546,6 @@ export default class Server {
552546

553547
return this.findPageComponents(dynamicRoute.page, query).then(
554548
result => {
555-
if (!(req.method === 'GET' || req.method === 'HEAD')) {
556-
res.statusCode = 405
557-
res.setHeader('Allow', ['GET', 'HEAD'])
558-
return this.renderError(null, req, res, pathname, query)
559-
}
560-
561549
return this.renderToHTMLWithComponents(
562550
req,
563551
res,

test/integration/api-support/test/index.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,12 @@ function runTests (serverless = false) {
197197
expect(data).toEqual({ nextjs: 'cool' })
198198
})
199199

200-
it('should return 405 on POST on pages', async () => {
200+
it('should return 200 on POST on pages', async () => {
201201
const res = await fetchViaHTTP(appPort, '/user', null, {
202202
method: 'POST'
203203
})
204204

205-
expect(res.status).toEqual(405)
205+
expect(res.status).toEqual(200)
206206
})
207207

208208
it('should return JSON on post on API', async () => {

test/integration/production/test/index.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ describe('Production Usage', () => {
8080
expect(res.status).toBe(404)
8181
})
8282

83-
it('should render 405 for POST on page', async () => {
83+
it('should render 200 for POST on page', async () => {
8484
const res = await fetch(`http://localhost:${appPort}/about`, {
8585
method: 'POST'
8686
})
87-
expect(res.status).toBe(405)
87+
expect(res.status).toBe(200)
8888
})
8989

9090
it('should render 404 for POST on missing page', async () => {

0 commit comments

Comments
 (0)