Commit 869bf0f1 authored by Lukáš Huvar's avatar Lukáš Huvar Committed by Tim Neutkens

Remove 405 from render method (#8323)

* Revert 405 on pages

* Modify tests
parent 5b115035
...@@ -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,
......
...@@ -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 () => {
......
...@@ -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 () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment