Skip to content

router.push to index.js works locally but not in Vercel #734

Answered by ahohnsen
e-rmkt asked this question in Web
Discussion options

You must be logged in to vote

Hey there 👋🏼

The issue actually doesn't lie with the redirection using router.push.

When I add a trip, it appears in the console as if the POST was unsuccessful, and I receive a 405 error. In the VS Code terminal, the following error message is displayed: "error Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client." This error occurs when attempting to modify the headers of the HTTP response after sending a response.

If we look at the code in /pages/api/trips, it seems like response.status(405).json({ message: "Method not allowed" }); is always executed at the end of the handler, regardless of whether any of the two previous if conditions were met or not. Yo…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ahohnsen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Web
Labels
None yet
2 participants