4 ms·
Next does technically support POST endpoints, in that API endpoints support any HTTP method and receive which one it is as part of the incoming request. Definit
by mcintyre1994 5y ago
Next does technically support POST endpoints, in that API endpoints support any HTTP method and receive which one it is as part of the incoming request. Definitely less nice than the way Remix handles it though.
- andrewingram 5y agoIt does, but the convention with forms is that you POST to the path you're on, rather than a different one. This is so that if there are any form validation errors you can easily re-render the current page with the errors added. To get this behaviour in Next, you'd have to hijack getServerSideProps (which is what the lib in one of your sibling comments does).
- mcintyre1994 5y agoAh that's useful context, thankyou! I didn't realise there was anything special going on with the path, I thought they were just doing a redirect back to that path from the server route if there were errors. What they're doing is much more clever and sophisticated than I realised, I definitely need to dive into it a bit more.