# Cloudflare Pages config for the data portal (data-portal skill).
# The skill fills the placeholders at assemble time:
#   __PROJECT_NAME__     the Pages project name
#   __D1_DATABASE_NAME__ the D1 database name  (<accountId>-<purpose>)
#   __D1_DATABASE_ID__   the id printed by `wrangler d1 create`
#   __R2_BUCKET_NAME__   the R2 bucket name    (<accountId>-<purpose>)
#   __PORTAL_INSTALL_ORIGIN__ the install's PUBLIC origin (https://<public-tunnel-hostname>), NOT the admin/operator host
name = "__PROJECT_NAME__"
pages_build_output_dir = "."
compatibility_date = "2024-01-01"
compatibility_flags = ["nodejs_compat"]

[[d1_databases]]
binding = "DB"
database_name = "__D1_DATABASE_NAME__"
database_id = "__D1_DATABASE_ID__"

# R2 binds by NAME and has no database_id analogue — the one asymmetry with the
# D1 block above. `binding` is the name the Pages Function reads off env.
[[r2_buckets]]
binding = "BUCKET"
bucket_name = "__R2_BUCKET_NAME__"

# Where the install answers, so a download of a device-held file can be signed
# and sent there. Public information: it is the hostname a client's browser
# ends up at. Use the PUBLIC host: the admin host is remote-auth-gated and the
# edge's signed HEAD probe 401s there, which 503s every download.
#
# Its partner, PORTAL_FETCH_SECRET, is deliberately NOT here. This file is
# committed to the account's assembled tree and the deploy publishes the
# directory it is handed, so a secret in it is a secret in a repo and one deploy
# from being served. Set it with `wrangler pages secret put`.
[vars]
PORTAL_INSTALL_ORIGIN = "__PORTAL_INSTALL_ORIGIN__"
