Minor Changes
-
#15231
3928b87Thanks @rururux! - Adds a new optionalgetRemoteSize()method to the Image Service API.Previously,
inferRemoteSize()had a fixed implementation that fetched the entire image to determine its dimensions.
With this new helper function that extendsinferRemoteSize(), you can now override or extend how remote image metadata is retrieved.This enables use cases such as:
- Caching: Storing image dimensions in a database or local cache to avoid redundant network requests.
- Provider APIs: Using a specific image provider's API (like Cloudinary or Vercel) to get dimensions without downloading the file.
For example, you can add a simple cache layer to your existing image service:
const cache = new Map(); const myService = { ...baseService, async getRemoteSize(url, imageConfig) { if (cache.has(url)) return cache.get(url); const result = await baseService.getRemoteSize(url, imageConfig); cache.set(url, result); return result; }, };
See the Image Services API reference documentation for more information.
-
#15077
a164c77Thanks @matthewp! - Updates the Integration API to addsetPrerenderer()to theastro:build:starthook, allowing adapters to provide custom prerendering logic.The new API accepts either an
AstroPrerendererobject directly, or a factory function that receives the default prerenderer:'astro:build:start': ({ setPrerenderer }) => { setPrerenderer((defaultPrerenderer) => ({ name: 'my-prerenderer', async setup() { // Optional: called once before prerendering starts }, async getStaticPaths() { // Returns array of { pathname: string, route: RouteData } return defaultPrerenderer.getStaticPaths(); }, async render(request, { routeData }) { // request: Request // routeData: RouteData // Returns: Response }, async teardown() { // Optional: called after all pages are prerendered } })); }
Also adds the
astro:static-pathsvirtual module, which exports aStaticPathsclass for adapters to collect all prerenderable paths from within their target runtime. This is useful when implementing a custom prerenderer that runs in a non-Node environment:// In your adapter's request handler (running in target runtime) import { App } from 'astro/app'; import { StaticPaths } from 'astro:static-paths'; export function createApp(manifest) { const app = new App(manifest); return { async fetch(request) { const { pathname } = new URL(request.url); // Expose endpoint for prerenderer to get static paths if (pathname === '/__astro_static_paths') { const staticPaths = new StaticPaths(app); const paths = await staticPaths.getAll(); return new Response(JSON.stringify({ paths })); } // Normal request handling return app.render(request); }, }; }
See the adapter reference for more details on implementing a custom prerenderer.
-
#15345
840fbf9Thanks @matthewp! - Adds a newemitClientAssetfunction toastro/assets/utilsfor integration authors. This function allows emitting assets that will be moved to the client directory during SSR builds, useful for assets referenced in server-rendered content that need to be available on the client.import { emitClientAsset } from 'astro/assets/utils'; // Inside a Vite plugin's transform or load hook const handle = emitClientAsset(this, { type: 'asset', name: 'my-image.png', source: imageBuffer, });
Patch Changes
-
#15423
c5ea720Thanks @matthewp! - Improves error message when a dynamic redirect destination does not match any existing route.Previously, configuring a redirect like
/categories/[category]→/categories/[category]/1in static output mode would fail with a misleading "getStaticPaths required" error. Now, Astro detects this early and provides a clear error explaining that the destination does not match any existing route. -
#15444
10b0422Thanks @AhmadYasser1! - FixesAstro.rewritereturning 404 when rewriting to a URL with non-ASCII charactersWhen rewriting to a path containing non-ASCII characters (e.g.,
/redirected/héllo), the route lookup compared encodeddistURLhrefs against decoded pathnames, causing the comparison to always fail and resulting in a 404. This fix compares against the encoded pathname instead. -
#15419
a18d727Thanks @ematipico! - Fixes an issue where theaddcommand could accept any arbitrary value, leading the possible command injections. Nowaddand--addaccepts
values that are only acceptable npmjs.org names. -
#15345
840fbf9Thanks @matthewp! - Fixes an issue where.sqlfiles (and other non-asset module types) were incorrectly moved to the client assets folder during SSR builds, causing "no such module" errors at runtime.The
ssrMoveAssetsfunction now reads the Vite manifest to determine which files are actual client assets (CSS and static assets like images) and only moves those, leaving server-side module files in place. -
#15422
68770efThanks @matthewp! - Upgrade to @astrojs/compiler@3.0.0-beta -
Updated dependencies [
a164c77,a18d727]:- @astrojs/internal-helpers@0.8.0-beta.1
- @astrojs/markdown-remark@7.0.0-beta.6