0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-27 22:19:04 -05:00

refactor: only delete cookies on error

This commit is contained in:
bholmesdev 2024-08-09 08:07:51 -04:00
parent dc306cfc41
commit 52aab84b6b

View file

@ -76,9 +76,13 @@ async function renderResult({
locals._actionPayload = { actionResult, actionName };
const response = await next();
context.cookies.delete(ACTION_QUERY_PARAMS.actionPayload);
if (actionResult.type === 'error') {
// Clear the cookie after rendering the error state.
// Otherwise, errors will reappear when revisiting a stale form.
// This is based on Laravel's implementation.
context.cookies.delete(ACTION_QUERY_PARAMS.actionPayload);
return new Response(response.body, {
status: actionResult.status,
statusText: actionResult.type,