Skip to content

Deployment Architecture

  • Directory.zugriff
    • config.json
    • Directoryfunctions
      • index.js
    • Directoryassets
      • favicon.ico

A deployment must contain a configuration file at ./config.json, functions returning dynamic responses at ./functions, and static assets at ./assets.

The configuration configures functions, static assets, preprocessors and postprocessors. Files not configured are stripped from the deployment.

{
"version": 1,
"functions": [{ "path": "/index.js", "pattern": "*" }],
"assets": [
"/favicon.ico",
"/404.html",
{ "path": "/menu.pdf", "cacheControl": "no-cache" },
...
],
"preprocessors": {
"puppets": {},
"redirects": []
},
"postprocessors": {
"interceptors": [
{
"status": 404,
"method": "GET",
"path": "/404.html"
}
]
}
}

Please note that paths referring to functions and static assets must be absolute from within their respective roots.

Learn more about preprocessors and postprocessors here.

A function must export a request handler, or listen to requests using addEventListener as described in the Runtime APIs.

Incoming request paths are matched against deduplicated patterns, with catch-all patterns processed last.

While patterns might look like regular expressions, they are not. A pattern can consist of lazy wildcards that are flexible in size and type, and regular characters that are not. For instance, * will match any path while /prefix/* will match any path prefixed with /prefix/ and *hello* will match any path containing hello. When checked, the incoming request path will always start and end with a /. The request handler, however, will receive the original path.

As seen in the example configuration file, assets can be configured to return a customised Cache-Control header. The value must start with max-age=, followed by the number of seconds to cache the asset, or be set to either no-cache or no-store.