Skip to content

svelte-adapter-azure-swa v0.17.0

Compare
Choose a tag to compare
@github-actions github-actions released this 02 Jul 22:19
47ca37c

This release contains two (likely non-breaking) features.

Allow customizing the node version

In production, your SvelteKit app will run a Node Azure Function to handle server requests. By default, this Azure Function uses Node 16. If you want to customize your Node version (version 18 is in public preview for Azure SWA), you can do so with the customStaticWebAppConfig adapter option to set platform.apiRuntime.

// svelte.config.js
import adapter from 'svelte-adapter-azure-swa';

/** @type {import('@sveltejs/kit').Config} */
const config = {
	kit: {
		adapter: adapter({
			customStaticWebAppConfig: {
				platform: {
					apiRuntime: 'node:18'
				}
			}
		})
	}
};

export default config;

Throw an error during build if the app declares /api routes

In production, Azure SWA will handle any request to routes starting with /api. If you also declare SvelteKit routes starting with /api, they will not be reachable in production and hitting them returns confusing errors (see #89 and #78 for context).

Because this, the adapter will now throw an error at build time and instruct you to rename the routes. If you do want to allow these routes for some reason, you can set allowReservedSwaRoutes in your adapter options. However, this will not start routing /api requests to your SvelteKit app, since SWA does not allow configuring the /api route.

Features