Skip to content

Commit

Permalink
Skip handler for POST requests when no action ID is found (#49119)
Browse files Browse the repository at this point in the history
Closes #48204. This shouldn't be a hard error but we should just
silently ignore.
  • Loading branch information
shuding authored May 3, 2023
1 parent 194da0b commit 0bc1b7e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/next/src/server/app-render/action-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ export async function handleAction({
actionId = formData.get('$$id') as string

if (!actionId) {
throw new Error('Invariant: missing action ID.')
// Return if no action ID is found, it could be a regular POST request
return
}
formData.delete('$$id')
bound = [formData]
Expand Down Expand Up @@ -124,7 +125,8 @@ export async function handleAction({
if (isFormAction) {
actionId = actionData.$$id as string
if (!actionId) {
throw new Error('Invariant: missing action ID.')
// Return if no action ID is found, it could be a regular POST request
return
}
const formData = formDataFromSearchQueryString(actionData)
formData.delete('$$id')
Expand Down

0 comments on commit 0bc1b7e

Please sign in to comment.