Releases: withastro/astro
[email protected]
Patch Changes
- #12420
acac0af
Thanks @ematipico! - Fixes an issue where the dev server returns a 404 status code when a user middleware returns a validResponse
.
[email protected]
Patch Changes
-
#12305
f5f7109
Thanks @florian-lefebvre! - Fixes a case where the error overlay would not escape the message -
#12402
823e73b
Thanks @ematipico! - Fixes a case where Astro allowed to call an action without usingAstro.callAction
. This is now invalid, and Astro will show a proper error.--- import { actions } from "astro:actions"; -const result = actions.getUser({ userId: 123 }); +const result = Astro.callAction(actions.getUser, { userId: 123 }); ---
-
#12401
9cca108
Thanks @bholmesdev! - Fixes unexpected 200 status in dev server logs for action errors and redirects.
[email protected]
Minor Changes
-
#12373
d10f918
Thanks @bholmesdev! - Changes the default behavior for Astro Action form requests to a standard POST submission.In Astro 4.x, actions called from an HTML form would trigger a redirect with the result forwarded using cookies. This caused issues for large form errors and return values that exceeded the 4 KB limit of cookie-based storage.
Astro 5.0 now renders the result of an action as a POST result without any forwarding. This will introduce a "confirm form resubmission?" dialog when a user attempts to refresh the page, though it no longer imposes a 4 KB limit on action return value.
Customize form submission behavior
If you prefer to address the "confirm form resubmission?" dialog on refresh, or to preserve action results across sessions, you can now customize action result handling from middleware.
We recommend using a session storage provider as described in our Netlify Blob example. However, if you prefer the cookie forwarding behavior from 4.X and accept the 4 KB size limit, you can implement the pattern as shown in this sample snippet:
// src/middleware.ts import { defineMiddleware } from 'astro:middleware'; import { getActionContext } from 'astro:actions'; export const onRequest = defineMiddleware(async (context, next) => { // Skip requests for prerendered pages if (context.isPrerendered) return next(); const { action, setActionResult, serializeActionResult } = getActionContext(context); // If an action result was forwarded as a cookie, set the result // to be accessible from `Astro.getActionResult()` const payload = context.cookies.get('ACTION_PAYLOAD'); if (payload) { const { actionName, actionResult } = payload.json(); setActionResult(actionName, actionResult); context.cookies.delete('ACTION_PAYLOAD'); return next(); } // If an action was called from an HTML form action, // call the action handler and redirect with the result as a cookie. if (action?.calledFrom === 'form') { const actionResult = await action.handler(); context.cookies.set('ACTION_PAYLOAD', { actionName: action.name, actionResult: serializeActionResult(actionResult), }); if (actionResult.error) { // Redirect back to the previous page on error const referer = context.request.headers.get('Referer'); if (!referer) { throw new Error('Internal: Referer unexpectedly missing from Action POST request.'); } return context.redirect(referer); } // Redirect to the destination page on success return context.redirect(context.originPathname); } return next(); });
Patch Changes
-
#12339
bdb75a8
Thanks @ematipico! - Adds an error whenAstro.rewrite()
is used to rewrite an on-demand route with a static route when using the"server"
output.This is a forbidden rewrite because Astro can't retrieve the emitted static route at runtime. This route is served by the hosting platform, and not Astro itself.
[email protected]
Patch Changes
-
#12311
bf2723e
Thanks @dinesh-58! - Addschecked
to the list of boolean attributes. -
#12363
222f718
Thanks @Fryuni! - Fixes code generated byastro add
command when adding a version of an integration other than the defaultlatest
. -
#12368
493fe43
Thanks @bluwy! - Improves error logs when executing commands -
#12355
c4726d7
Thanks @apatel369! - Improves error reporting for invalid frontmatter in MDX files during theastro build
command. The error message now includes the file path where the frontmatter parsing failed.
@astrojs/[email protected]
[email protected]
Minor Changes
-
#12083
9263e96
Thanks @Princesseuh! - Reworks the experience of creating a new Astro project using thecreate astro
CLI command.- Updates the list of templates to include Starlight and combines the "minimal" and "basics" templates into a new, refreshed "Basics" template to serve as the single, minimal Astro project starter.
- Removes the TypeScript question. Astro is TypeScript-only, so this question was often misleading. The "Strict" preset is now the default, but it can still be changed manually in
tsconfig.json
. astro check
is no longer automatically added to the build script.- Added a new
--add
flag to install additional integrations after creating a project. For example,pnpm create astro --add react
will create a new Astro project and install the React integration.
[email protected]
@astrojs/[email protected]
[email protected]
Patch Changes
-
#12333
836cd91
Thanks @imattacus! - Destroy the server response stream if async error is thrown -
#12358
7680349
Thanks @spacedawwwg! - HonorsinlineAstroConfig
parameter ingetViteConfig
when creating a logger -
#12353
35795a1
Thanks @hippotastic! - Fixes an issue in dev server watch file handling that could cause multiple restarts for a single file change. -
#12351
5751488
Thanks @florian-lefebvre! - Reverts a change made in4.16.6
that prevented usage ofastro:env
secrets inside middleware in SSR -
#12346
20e5a84
Thanks @bluwy! - Fixes sourcemap generation when prefetch is enabled -
#12349
1fc83d3
Thanks @norskeld! - Fixes thegetImage
options type so it properly extendsImageTransform
[email protected]
Patch Changes
-
#12338
9ca89b3
Thanks @situ2001! - ResetsNODE_ENV
to ensure install command run in dev mode -
#12286
9d6bcdb
Thanks @florian-lefebvre! - Fixes a case where a warning for experimentalastro:env
support would be shown when using an adapter but not actually usingastro:env
-
#12342
ffc836b
Thanks @liruifengv! - Fixes a typo in the command name of the CLI -
#12301
0cfc69d
Thanks @apatel369! - Fixes an issue with action handler context by passing the correct context (ActionAPIContext
). -
#12312
5642ef9
Thanks @koyopro! - Fixes an issue where usinggetViteConfig()
returns incorrect and duplicate configuration -
#12245
1d4f6a4
Thanks @bmenant! - Addcomponents
property to MDXInstance type definition (RenderResult and module import) -
#12340
94eaeea
Thanks @ematipico! - Fixes an issue where Astro actions didn't work whenbase
was different from/