vercelRoutes
The routes of config.json, in the order Vercel reads them (B2): 1.
The routes of config.json, in the order Vercel reads them (B2):
- a page the app's rules apply to (
mode: "handler") goes to the function before the filesystem handler, so its rules and the host routing run for it, and its prerendered file is not served; - a static page with headers gets them from a route that only adds headers (
continue: true, as the Vercelheadersconversion does): the file still comes from the CDN, and no function runs for it; - the immutable folders get their year-long rule the same way, before the filesystem handler;
- the filesystem handler; then, for an immutable folder, a missing file is a
no-store404 (a year-long rule must not stick to a fall-through response); then the catch-all to the function. Before all of them, when the app lists its hosts (security.allowedHosts), a request whose Host is not listed goes to the function first (missinghost condition): the function answers the handler's 400, and no file is served.
Import#
ts
import { vercelRoutes } from "@shadow-js/dusk/vercel";
Signature#
ts
function vercelRoutes(
pages: readonly StaticPage[],
fn: string,
immutable: readonly string[] = [],
allowedHosts: readonly string[] = [],
): Array<Record<string, unknown>>
Parameters#
| Name | Description |
|---|---|
pages |
How each prerendered page is answered. |
fn |
The function name. |
immutable |
The URL folders of the immutable files (see immutableFolders). |
allowedHosts |
The app's host list; absent or empty for no host routing. |