Deployed Next.js Application cannot be accessed by POST request


I got a problem when trying to access deployed instance of a web with POST request. The use case is when an external gateway redirect back to the page with extra payload.

Is there anyway I can change the request (with netlify rewrite ?) or make it render the page normally ?

Here is a minimal Netlify site that can be use to reproduce the problem :
Repository: GitHub - hamzaabamboo/test-post-404

Steps to reproduce:
1 - access the web with GET request: the web should return correctly
2 - access the web with POST request and form-url-encoded payload (Alternatively, you could click the only button on the page): the web returned 404 not found error

Thank you

Hey @hamzaabamboo,

Netlify only serves GET requests by default. The only time we actually listen for POST requests on your site if when you’re using Netlify Forms. Even then, if we don’t receive a form data with the exact information that you’ve defined in the form, it would still fail.

The only other way to configure Netlify to handle POST requests would be by sending the requests to Netlify Functions. You might be using that POST data inside the Netlify Function, process it and then redirect to some page.

Could you let us know what do you intend to do on the page with the posted data? Maybe we can suggest something else, or a workaround based on that?

1 Like