actionCookieForwarding() — astro Function Reference
Architecture documentation for the actionCookieForwarding() function in middleware.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 456f61e7_3d31_64cc_3eee_4e71aad5fb7a["actionCookieForwarding()"] 67028c0d_9e9d_0a3c_6481_1f8d3d7ffb11["middleware.ts"] 456f61e7_3d31_64cc_3eee_4e71aad5fb7a -->|defined in| 67028c0d_9e9d_0a3c_6481_1f8d3d7ffb11 style 456f61e7_3d31_64cc_3eee_4e71aad5fb7a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/e2e/fixtures/actions-blog/src/middleware.ts lines 4–36
const actionCookieForwarding = defineMiddleware(async (ctx, next) => {
if (ctx.isPrerendered) return next();
const { action, setActionResult, serializeActionResult } = getActionContext(ctx);
const payload = ctx.cookies.get('ACTION_PAYLOAD');
if (payload) {
const { actionName, actionResult } = payload.json();
setActionResult(actionName, actionResult);
ctx.cookies.delete('ACTION_PAYLOAD');
return next();
}
if (action?.calledFrom === 'form' && ctx.url.searchParams.has('actionCookieForwarding')) {
const actionResult = await action.handler();
ctx.cookies.set('ACTION_PAYLOAD', {
actionName: action.name,
actionResult: serializeActionResult(actionResult),
});
if (actionResult.error) {
const referer = ctx.request.headers.get('Referer');
if (!referer) {
throw new Error('Internal: Referer unexpectedly missing from Action POST request.');
}
return ctx.redirect(referer);
}
return ctx.redirect(ctx.originPathname);
}
return next();
});
Domain
Subdomains
Source
Frequently Asked Questions
What does actionCookieForwarding() do?
actionCookieForwarding() is a function in the astro codebase, defined in packages/astro/e2e/fixtures/actions-blog/src/middleware.ts.
Where is actionCookieForwarding() defined?
actionCookieForwarding() is defined in packages/astro/e2e/fixtures/actions-blog/src/middleware.ts at line 4.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free