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:
parent
dc306cfc41
commit
52aab84b6b
1 changed files with 5 additions and 1 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue