TrayPage Docs

Configuration reference

Every environment variable and binding for self-hosted TrayPage, and what each one means.

This is the list of settings for the self-hosted edition. On Docker / VPS you set them in .env (deploy/docker/.env.example); on Cloudflare you set them in vars in wrangler.jsonc and as secrets.

"Required" means TrayPage cannot start, or cannot work correctly, without it.

Basics

NameRequiredMeaning
APP_ORIGINRequired in productionThe app URL (for example https://traypage.example.com). Write only the origin (a trailing / is fine; a path, query, or user name is a configuration error and the app does not start). Used to build share URLs and sign-in links, and as the allowed origin for authentication. Required for Docker
VIEWER_ORIGINRequired in productionThe URL of the viewer host that serves page content (for example https://view.traypage.example.com). Write only the origin (a trailing / is fine; a path, query, or user name is a configuration error). With it set, the viewer host only answers for shared page content, robots.txt (which forbids all crawling) and the health check (/health), and page content is served only from the viewer host (not from the app host). In production, use a host name different from APP_ORIGIN (not its www. host either). Sharing the host name and splitting only the port (for example localhost:3000 and localhost:3001) is for local testing only (cookies are not split by port). Internationalized domain names can be written as they are. A value that cannot be read, or that cannot be told apart from APP_ORIGIN (same host name and same port), is a configuration error (Docker does not start; on Cloudflare responses are 500, except public static files such as JS, CSS, and images). Required for Docker
VIEWER_HOSTOptional (compatibility)The viewer host is taken from VIEWER_ORIGIN, so you can leave this out. It is accepted for compatibility with older settings; if you write it, use the same host name as VIEWER_ORIGIN (for example view.traypage.example.com; no https://). A different host, or VIEWER_HOST without VIEWER_ORIGIN, is a configuration error
BETTER_AUTH_SECRETRequiredThe key that signs sign-in sessions. Generate one with something like openssl rand -hex 32. Changing it signs everyone out
VIEWER_TICKET_SECRETRequired on CloudflareThe key for the short-lived (5 minute) signed tickets handed to the viewer host. On Docker, BETTER_AUTH_SECRET is used if unset. On Cloudflare, use a different value from BETTER_AUTH_SECRET
TRAYPAGE_EDITIONOptionalself_hosted removes usage limits and trials, and disables operator-only features (including the daily summary notification). It also hides the pages meant for tray.page (hosted): the landing page, pricing, terms, privacy policy, and contact form. / goes to the sign-in screen (or to the app when signed in). The docs (/docs) stay available. The Docker setup sets it automatically and the Cloudflare template already sets it. If unset or unrecognized, behavior is the same as tray.page (hosted)
TRAYPAGE_LICENSE_KEYOptionalThe Enterprise license key (starts with tp1.). See License and Enterprise features
ENVIRONMENTOptionalproduction keeps the test-only login disabled at all times and ignores the settings that turn off the rate limits (AUTH_RATE_LIMIT, API_RATE_LIMIT). The Docker image, the bundled compose setup, and the AWS and Cloudflare templates already set production

Database

NameApplies toMeaning
DATABASE_URLDockerThe Postgres connection string (for example postgres://user:password@host:5432/db?sslmode=require). If unset on Docker, the bundled Postgres is used
DATABASE_POOL_MAXDockerMaximum connection pool size. Defaults to 10
POSTGRES_PASSWORDDocker (compose)Password of the bundled Postgres. Decide it before the first start
HYPERDRIVECloudflareThe Hyperdrive binding. You pick an existing configuration in the button flow

The app creates tables automatically on startup (on Cloudflare, on the first access).

Page content storage

NameApplies toMeaning
PAGE_BUCKETCloudflareThe R2 bucket binding. Created automatically by the button
S3_ENDPOINTDockerEndpoint of the S3-compatible storage. If unset on Docker, the bundled SeaweedFS is used
S3_BUCKETDockerBucket name. Defaults to traypage-pages
S3_ACCESS_KEY_IDDockerAccess key ID
S3_SECRET_ACCESS_KEYDockerSecret access key
S3_REGIONDockerRegion. The AWS region for AWS S3, or auto for R2
S3_ADDRESSING_STYLEDockerpath (default) or virtual

On Cloudflare, PAGE_BUCKET is used when present. On Docker, S3-compatible storage is used when the S3_* values are complete.

Email

NameApplies toMeaning
EMAIL_FROMBothThe sender (for example TrayPage <noreply@example.com>). Required on the self-hosted edition: use an address on a domain your email service can send from. The tray.page sender is never used. If it is unset, Docker does not start when an external SMTP server or Resend is configured (with only the bundled Mailpit, email is sent from TrayPage <noreply@localhost>); on Cloudflare, every email fails and the log shows EMAIL_FROM is required
RESEND_API_KEYBothFor compatibility with older versions. Email is sent through Resend only when this is set, and it takes priority over the EMAIL binding and SMTP
SMTP_HOSTDockerSMTP server host name. Used when RESEND_API_KEY is not set (the default on Docker)
SMTP_PORTDockerPort. If unset, 465 when SMTP_SECURE is enabled, otherwise 587
SMTP_SECUREDockertrue uses TLS from the start (port 465); otherwise STARTTLS
SMTP_USER / SMTP_PASSWORDDockerSMTP credentials (omit if no authentication is needed)
MAIL_CATCHER_SMTP_HOSTDockerHost name of a mail catcher that never delivers to the internet. When SMTP_HOST matches it, email is sent from TrayPage <noreply@localhost> even without EMAIL_FROM. The bundled compose setup sets it to the bundled Mailpit (mailpit); you do not set it yourself
EMAILCloudflareThe Cloudflare Email Service binding. Included in the template. When present, email is sent through it (the default on Cloudflare; the sender domain must be registered)
MAILPIT_URLDevelopmentWhen no sender is configured, email is sent to this Mailpit API (default http://localhost:8025). The bundled compose setup sends to Mailpit over SMTP by default

Notification emails

Comments, replies, new versions, and completed reviews are emailed to the people involved. No extra configuration is needed: it works as soon as one of the senders above is configured.

  • Emails are not sent one by one. For each recipient, events are combined into a single email 5 minutes after the last event, or 15 minutes after the first one. While a conversation is active, one person gets about one email every 5 minutes.
  • Right before sending, TrayPage checks that the recipient can still see the page. People who are no longer in the sharing scope get nothing.
  • Recipients can stop the emails under "Email notifications" in their account settings, or with the unsubscribe link in each email.
  • Links in the email use APP_ORIGIN. On Cloudflare, while APP_ORIGIN is not set, the URL the action came from is used (on Docker, emails cannot be sent without it). Set APP_ORIGIN so that links always use one URL.

How the batching job runs depends on the setup.

SetupHow it runs
Docker / AWSThe server sends every minute. With several servers, two of them never deliver to the same person at the same time
CloudflareA cron (triggers.crons in wrangler.jsonc, or notification_cron with Terraform) starts the job. The default is every 5 minutes and you can change it (a longer interval delays the emails by that much). If you remove it, notification emails are not sent

On Cloudflare, each cron run queries the database once even when there is nothing to send. A database that suspends when idle (such as the Neon free tier) stays awake because of this. Use a longer cron interval if you want it to suspend.

Delivery is at least once. In rare cases, for example when the server stops right after the email was accepted, the same notification can arrive twice. A failed send is retried at increasing intervals for about 10 hours. Notifications that stay undeliverable, for example because the sender domain is not registered yet, are deleted after 14 days. If recording a notification fails (for example during a brief database outage), the original action such as the comment still succeeds and only that notification is lost.

Sign-in

NameMeaning
GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRETThe OAuth client for Google sign-in. The redirect URI is <APP_ORIGIN>/api/auth/callback/google
NEXT_PUBLIC_GOOGLE_AUTHSet to 1 to show Google sign-in on the sign-in screen
OIDC_ISSUERThe issuer of your company IdP (Okta, Keycloak, and so on) for sign-in, e.g. https://example.okta.com. Write it exactly as the issuer in the IdP's discovery document, including any trailing /. The discovery URL (ending in /.well-known/openid-configuration) cannot be used. Use https (http is allowed only for localhost)
OIDC_CLIENT_ID / OIDC_CLIENT_SECRETThe ID and secret of the client you registered in the IdP. Store the secret as a secret on Cloudflare, or in .env with Docker. The redirect URI to register in the IdP is <APP_ORIGIN>/api/auth/oauth2/callback/oidc
OIDC_DISPLAY_NAMEThe IdP name shown on the sign-in button, e.g. Okta. Defaults to SSO
OIDC_ASSUME_EMAIL_VERIFIEDSet to 1 to treat email addresses from an IdP that does not send email_verified as verified. Off by default. Use it only if you can guarantee that the IdP confirms who owns each address (not with Microsoft Entra ID). When the IdP sends anything other than true (boolean) or "true" (string), it is never treated as verified
OIDC_CLIENT_AUTH_METHODHow the client secret is sent. client_secret_basic (default; in the Authorization header) or client_secret_post (in the request body). Match the client authentication method registered in the IdP
LOGIN_METHODSLimits the sign-in methods (comma-separated: magic_link (email link), google, oidc). When unset, every configured method is used. Set oidc to sign in only through your IdP. If none of the listed methods can be used, nobody can sign in (no other method is turned on instead; remove it to sign in with email links)

IdP sign-in is turned on only when OIDC_ISSUER, OIDC_CLIENT_ID, and OIDC_CLIENT_SECRET are all set. For the steps and what happens on sign-in, see Security notes.

Sign-up restriction

If unset, anyone who can receive a sign-in link can create an account. For how the settings combine and behave, see Security notes. Existing users can always sign in.

NameMeaning
SIGNUP_MODEopen (default) or invite_only. With invite_only, only email addresses that match the allowlist and addresses invited to an organization or a page can sign up. Unset, empty, or whitespace only means open. Any other value lets only allowlisted addresses sign up (not invited ones) and logs signup_policy_invalid
SIGNUP_ALLOWED_EMAIL_DOMAINSEmail domains allowed to sign up (comma-separated, e.g. example.com,example.org). Exact match, case-insensitive. Setting it with open lets only matching addresses sign up
SIGNUP_ALLOWED_EMAILSEmail addresses allowed to sign up (comma-separated). With invite_only, put your first administrator here

The Cloudflare template (wrangler.jsonc) includes the defaults (open and empty allowlists). On AWS, set them with signup_mode, signup_allowed_email_domains, and signup_allowed_emails in Terraform.

Sign-in rate limit

Authentication actions, such as sign-in (sending and opening the email link, passwords) and connecting AI agents (OAuth), are limited per client IP address. Over the limit, requests get "Too many requests" (HTTP 429) for a while, usually about a minute. Counts are stored in the database, so they add up across multiple servers. It is on by default. The bundled Docker image and compose setup and the AWS and Cloudflare templates set ENVIRONMENT=production, so the settings that turn off the limits (AUTH_RATE_LIMIT, API_RATE_LIMIT) have no effect there.

NameApplies toMeaning
TRUSTED_CLIENT_IP_HEADERDockerThe header to read the client IP address from. The bundled compose setup (behind Caddy) sets x-forwarded-for, and so does the AWS Terraform module (ECS + ALB). For headers that are appended to, such as X-Forwarded-For, the last value (the client as seen by the proxy right in front of the app) is used. If unset, the address connecting to the app is used. Not needed on Cloudflare (the client IP that Cloudflare adds is used)
  • If you put another load balancer or CDN in front of Caddy, everyone is counted as the same IP (the one in front) and hits the limit together. In that case, set trusted_proxies in the Caddyfile so Caddy keeps the client IP passed on by the proxy in front (see "認証のレート制限" (auth rate limit) in deploy/docker/README.md).
  • In the AWS standard setup (ECS + ALB), the ALB appends the client IP to the end of X-Forwarded-For and the app uses that last value. The Terraform module sets TRUSTED_CLIENT_IP_HEADER=x-forwarded-for. Without it, everyone is counted as the ALB's IP and hits the limit together.
  • If you expose the app directly without a proxy, do not set TRUSTED_CLIENT_IP_HEADER. Clients can write any header they like, which would let them get around the limit.

Rate limits on other actions

Creating pages and adding versions, publishing and widening who can see a page, viewing and exporting pages (HTML, PDF, print), commenting, actions that send email (sharing a page with a person, inviting members), and sending the support form are also limited. This is on by default in the self-hosted edition too.

  • Narrowing who can see a page and revoking share links or individual access are not counted, so you can take back a page you published by mistake right away, regardless of the limits.

  • PDF export is limited to 10 per minute and 60 per hour per person on top of the viewing limit, because each export renders the page in a browser.

  • Signed-in people are counted per person. Actions through access tokens or AI agents (MCP) count toward the token owner.

  • The support form and page views by people who are not signed in are counted per client IP address. The IP address is read the same way as for the sign-in rate limit (TRUSTED_CLIENT_IP_HEADER above).

  • The limits are set so that normal use (an AI agent creating several pages in a row, leaving comments one after another during a review) does not hit them. For example, creating pages and adding versions allows 30 per minute and 300 per hour per person, comments allow 60 per minute and 600 per hour, and the support form allows 5 per 10 minutes and 20 per day from the same IP address.

  • Over the limit, the app shows how long to wait (for example, "Try again in about 10 minutes"). When both a short and a long limit are reached, the wait covers both. The API returns HTTP 429 with a Retry-After header (in seconds), and AI agents get a tool error that states the limit that was exceeded and how many seconds to wait. The limit lifts by itself once that time has passed.

Server (Docker)

NameMeaning
PORTThe port the app container listens on. Defaults to 8080. In compose it is not exposed; only Caddy connects to it
HOSTThe address to listen on. Defaults to 0.0.0.0

Compose settings (Docker)

NameMeaning
COMPOSE_PROFILESWhich services to start: postgres (bundled Postgres), s3 (bundled SeaweedFS), and mailpit (a local mail catcher), comma-separated
TRAYPAGE_IMAGEThe image to use. Defaults to ghcr.io/8d-inc/tray-page:latest. In production, pin a version such as :v1.2.3
HTTP_PORT / HTTPS_PORTPorts Caddy listens on. 80 and 443 in production; locally, the same port written in APP_ORIGIN
MAILPIT_UI_PORTPort of the Mailpit UI. Defaults to 8025 (exposed only on your own machine)

Cloudflare bindings

NameMeaning
HYPERDRIVEConnection to the database (required)
PAGE_BUCKETR2 bucket for page content (required)
EMAILEmail Service, for sending email
BROWSERBrowser Run, for faithful PDF export (optional)
REVIEW_SESSIONSDurable Objects, used to notify a waiting CLI as soon as a review is finished (optional; without it, the CLI checks every few seconds)
ASSETSStatic files for the UI (set in the template; no change needed)

Settings you normally do not set

The following are for operating tray.page (hosted), development, or testing. Do not set them on a self-hosted instance.

NamePurpose
E2E_LOGIN_SECRETLogin for automated tests. Always disabled when ENVIRONMENT=production
AUTH_RATE_LIMIToff removes the sign-in rate limit (for development and automated tests). Ignored when ENVIRONMENT=production
API_RATE_LIMIToff removes the rate limits on other actions (for development and automated tests). Ignored when ENVIRONMENT=production
OPERATOR_EMAILS, OPERATOR_SLACK_WEBHOOK_URL, DEFAULT_TRIAL_DAYSOperator features of the hosted service. Disabled in the self-hosted edition
SUPPORT_EMAIL, SUPPORT_EMAILSContact addresses for the hosted service's support form
STORAGE_DIRA local folder used when no storage is configured at all (for tests)
BETTER_AUTH_URLOn Docker this is set from APP_ORIGIN automatically
NEXT_PUBLIC_APP_URLAn old setting name that is no longer read. Set APP_ORIGIN instead