diff --git a/packages/astro/src/actions/runtime/middleware.ts b/packages/astro/src/actions/runtime/middleware.ts index 4e8c3fcd94..a41b6cb576 100644 --- a/packages/astro/src/actions/runtime/middleware.ts +++ b/packages/astro/src/actions/runtime/middleware.ts @@ -124,17 +124,15 @@ async function handlePost({ }); } - return redirectWithResult({ context, next, actionName, actionResult }); + return redirectWithResult({ context, actionName, actionResult }); } async function redirectWithResult({ context, - next, actionName, actionResult, }: { context: APIContext; - next: MiddlewareNext; actionName: string; actionResult: SafeResult; }) { @@ -146,7 +144,9 @@ async function redirectWithResult({ if (actionResult.error) { const referer = context.request.headers.get('Referer'); - if (!referer) return next(); + if (!referer) { + throw new Error('Internal: Referer unexpectedly missing from Action POST request.'); + } return context.redirect(referer); } @@ -183,5 +183,5 @@ async function handlePostLegacy({ context, next }: { context: APIContext; next: const action = baseAction.bind(context); const actionResult = await action(formData); - return redirectWithResult({ context, next, actionName, actionResult }); + return redirectWithResult({ context, actionName, actionResult }); }