#131133a26e45 Thanks @unprintable123! - Fixes the bug that rewrite will pass encoded url to the dynamic routing and cause params mismatch.
#1311123978dd Thanks @ascorbic! - Fixes a bug that caused injected endpoint routes to return not found when trailingSlash was set to always
#131120fa5c82 Thanks @ematipico! - Fixes a bug where the i18n middleware was blocking a server island request when the prefixDefaultLocale option is set to true
When the trailingSlash option is set to always or never, on-demand rendered pages will now redirect to the correct URL when the trailing slash doesn’t match the configuration option. This was previously the case for static pages, but now works for on-demand pages as well.
Now, it doesn’t matter whether your visitor navigates to /about/, /about, or even /about///. In production, they’ll always end up on the correct page. For GET requests, the redirect will be a 301 (permanent) redirect, and for all other request methods, it will be a 308 (permanent, and preserve the request method) redirect.
In development, you’ll see a helpful 404 page to alert you of a trailing slash mismatch so you can troubleshoot routes.
Now, you can redirect routes either internally to another path or externally by providing a URL beginning with http or https:
astro.config.mjs
import { defineConfig } from'astro/config';
exportdefaultdefineConfig({
redirects: {
'/blog': 'https://example.com/blog',
'/news': {
status: 302,
destination: 'https://example.com/news',
},
},
});
#130840f3be31 Thanks @ematipico! - Adds a new experimental virtual module astro:config that exposes a type-safe subset of your astro.config.mjs configuration
The virtual module exposes two sub-paths for controlled access to your configuration:
astro:config/client: exposes config information that is safe to expose to the client.
astro:config/server: exposes additional information that is safe to expose to the server, such as file/dir paths.
To enable this new virtual module, add the experimental.serializeManifest feature flag to your Astro config:
astro.config.mjs
import { defineConfig } from'astro/config';
exportdefaultdefineConfig({
experimental: {
serializeManifest: true,
},
});
Then, you can access the module in any file inside your project to import and use values from your Astro config:
For a complete overview, and to give feedback on this experimental API, see the Serialized Manifest RFC.
🐞 Patch Changes
#130492ed4bd9 Thanks @florian-lefebvre! - Updates astro add tailwind to add the @tailwindcss/vite plugin instead of the @astrojs/tailwind integration
#129945361755 Thanks @ascorbic! - Returns a more helpful 404 page in dev if there is a trailing slash mismatch between the route requested and the trailingSlash configuration
#12666037495d Thanks @Thodor12! - Added additional generated typings for the content layer
#13059e36837f Thanks @ascorbic! - Fixes a bug that caused tsconfig path aliases to break if there was more than one wildcard pattern
#13045c7f1366 Thanks @mtwilliams-code! - Fixes a bug where the some utility functions of the astro:i18n virtual module would return an incorrect result when trailingSlash is set to never
#129868911bda Thanks @wetheredge! - Updates types and dev toolbar for ARIA 1.2 attributes and roles
#128928f520f1 Thanks @louisescher! - Adds a more descriptive error when a content collection entry has an invalid ID.
#13031f576519 Thanks @florian-lefebvre! - Updates the server islands encoding logic to only escape the script end tag open delimiter and opening HTML comment syntax
#130261d272f6 Thanks @ascorbic! - Fixes a regression that prevented the import of Markdown files as raw text or URLs.
#129989ce0038 Thanks @Kynson! - Fixes the issue that audit incorrectly flag images as above the fold when the scrolling container is not body
#129902e12f1d Thanks @ascorbic! - Fixes a bug that caused references to be incorrectly reported as invalid
#129842d259cf Thanks @ascorbic! - Fixes a bug in dev where files would stop being watched if the Astro config file was edited
#129842d259cf Thanks @ascorbic! - Fixes a bug where the content layer would use an outdated version of the Astro config if it was edited in dev
#12982429aa75 Thanks @bluwy! - Fixes an issue where server islands do not work in projects that use an adapter but only have prerendered pages. If an adapter is added, the server island endpoint will now be added by default.
#1299578fd73a Thanks @florian-lefebvre! - Fixes a case where astro:actions types would not work when using src/actions.ts
#12733bbf1d88 Thanks @ascorbic! - Fixes a bug that caused the dev server to return an error if requesting “//”
#13001627aec3 Thanks @ascorbic! - Fixes a bug that caused Astro to attempt to inject environment variables into non-source files, causing performance problems and broken builds
#129801a026af Thanks @florian-lefebvre! - Fixes a case where setting the status of a page to 404 in development would show the default 404 page (or custom one if provided) instead of using the current page
#12934673a518 Thanks @ematipico! - Fixes a regression where the Astro Container didn’t work during the build, using pnpm
#12955db447f2 Thanks @martrapp! - Lets TypeScript know about the “blocking” and “disabled” attributes of the <link> element.
#12922faf74af Thanks @adamchal! - Improves performance of static asset generation by fixing a bug that caused image transforms to be performed serially. This fix ensures that processing uses all CPUs when running in a multi-core environment.
#129473c2292f Thanks @ascorbic! - Fixes a bug that caused empty content collections when running dev with NODE_ENV set
#12927ad2a752 Thanks @ematipico! - Fixes a bug where Astro attempted to decode a request URL multiple times, resulting in an unexpected behaviour when decoding the character %
#129120c0c66b Thanks @florian-lefebvre! - Improves the config error for invalid combinations of context and access properties under env.schema
#129353d47e6b Thanks @AirBorne04! - Fixes an issue where Astro.locals coming from an adapter weren’t available in the 404.astro, when using the astro dev command,
#1292544841fc Thanks @ascorbic! - Ensures image styles are not imported unless experimental responsive images are enabled
#129268e64bb7 Thanks @oliverlynch! - Improves remote image cache efficiency by separating image data and metadata into a binary and sidecar JSON file.
#129208b9d530 Thanks @bluwy! - Processes markdown with empty body as remark and rehype plugins may add additional content or frontmatter
#12918fd12a26 Thanks @lameuler! - Fixes a bug where the logged output path does not match the actual output path when using build.format: 'preserve'
#126762ffc0fc Thanks @koyopro! - Allows configuring Astro modules TypeScript compilation with the vite.esbuild config
#12938dbb04f3 Thanks @ascorbic! - Fixes a bug where content collections would sometimes appear empty when first running astro dev
#1293730edb6d Thanks @ematipico! - Fixes a bug where users could use Astro.request.headers during a rewrite inside prerendered routes. This an invalid behaviour, and now Astro will show a warning if this happens.
#1293730edb6d Thanks @ematipico! - Fixes an issue where the use of Astro.rewrite would trigger the invalid use of Astro.request.headers
#1287773a0788 Thanks @bluwy! - Fixes sourcemap warning generated by the astro:server-islands Vite plugin
#129062d89492 Thanks @ascorbic! - Fixes a bug that caused pages that return an empty array from getStaticPath to match every path
011fa0f Thanks @florian-lefebvre! - Fixes a case where astro:content types would be erased when restarting the dev server
#12907dbf1275 Thanks @florian-lefebvre! - Fixes a regression around the server islands route, which was not passed to the adapters astro:build:done hook
#12818579bd93 Thanks @ascorbic! - Fixes race condition where dev server would attempt to load collections before the content had loaded
#12883fbac92f Thanks @kaytwo! - Fixes a bug where responses can be returned before session data is saved
#128153acc654 Thanks @ericswpark! - Some non-index files that were incorrectly being treated as index files are now excluded
#1278196c4b92 Thanks @ascorbic! - Fixes a regression that caused default() to not work with reference()
#12820892dd9f Thanks @ascorbic! - Fixes a bug that caused cookies to not be deleted when destroying a session
#12864440d8a5 Thanks @kaytwo! - Fixes a bug where the session ID wasn’t correctly regenerated
#12768524c855 Thanks @ematipico! - Fixes an issue where Astro didn’t print error logs when Astro Islands were used in incorrect cases.
#12814f12f111 Thanks @ematipico! - Fixes an issue where Astro didn’t log anything in case a file isn’t created during the build.
#12875e109002 Thanks @ascorbic! - Fixes a bug in emulated legacy collections where the entry passed to the getCollection filter function did not include the legacy entry fields.
#12768524c855 Thanks @ematipico! - Fixes an issue where Astro was printing the incorrect output format when running the astro build command
#1281070a9f0b Thanks @louisescher! - Fixes server islands failing to check content-type header under certain circumstances
Sometimes a reverse proxy or similar service might modify the content-type header to include the charset or other parameters in the media type of the response. This previously wasn’t handled by the client-side server island script and thus removed the script without actually placing the requested content in the DOM. This fix makes it so the script checks if the header starts with the proper content type instead of exactly matching text/html, so the following will still be considered a valid header: text/html; charset=utf-8
#128167fb2184 Thanks @ematipico! - Fixes an issue where an injected route entrypoint wasn’t correctly marked because the resolved file path contained a query parameter.
This fixes some edge case where some injected entrypoint were not resolved when using an adapter.
Sessions are used to store user state between requests for server-rendered pages, such as login status, shopping cart contents, or other user-specific data.
---
exportconstprerender=false; // Not needed in 'server' mode
constcart=await Astro.session.get('cart');
---
<ahref="/checkout">🛒 {cart?.length??0} items</a>
Sessions are available in on-demand rendered/SSR pages, API endpoints, actions and middleware. To enable session support, you must configure a storage driver.
If you are using the Node.js adapter, you can use the fs driver to store session data on the filesystem:
astro.config.mjs
{
adapter: node({ mode: 'standalone' }),
experimental: {
session: {
// Required: the name of the unstorage driver
driver: "fs",
},
},
}
If you are deploying to a serverless environment, you can use drivers such as redis, netlify-blobs, vercel-kv, or cloudflare-kv-binding and optionally pass additional configuration options.
For more information, including using the session API with other adapters and a full list of supported drivers, see the docs for experimental session support. For even more details, and to leave feedback and participate in the development of this feature, the Sessions RFC.
Astro 5.1 introduces a new helper function, getActionPath() to give you more flexibility when calling your action.
Calling getActionPath() with your action returns its URL path so you can make a fetch() request with custom headers, or use your action with an API such as navigator.sendBeacon(). Then, you can handle the custom-formatted returned data as needed, just as if you had called an action directly.
This example shows how to call a defined like action passing the Authorization header and the keepalive option:
#12786e56af4a Thanks @ematipico! - Fixes an issue where Astro i18n didn’t properly show the 404 page when using fallback and the option prefixDefaultLocale set to true.
#127638da2318 Thanks @rbsummers! - Fixed changes to vite configuration made in the astro:build:setup integration hook having no effect when target is “client”
#1276736c1e06 Thanks @ascorbic! - Clears the content layer cache when the Astro config is changed
#12597564ac6c Thanks @florian-lefebvre! - Fixes an issue where image and server islands routes would not be passed to the astro:routes:resolved hook during builds
#12718ccc5ad1 Thanks @ematipico! - Fixes an issue where Astro couldn’t correctly handle i18n fallback when using the i18n middleware
#12728ee66a45 Thanks @argyleink! - Adds type support for the closedby attribute for <dialog> elements
#12709e3bfd93 Thanks @mtwilliams-code! - Fixes a bug where Astro couldn’t correctly parse params and props when receiving i18n fallback URLs