Environment Variables Configuration Guide
Rin requires two types of environment variables: Variables (plaintext) and Secrets (encrypted).
Quick Reference
Variables (Plaintext)
These variables are stored in plaintext in wrangler.toml or GitHub Actions and control feature flags and basic parameters.
Site Configuration
Site configuration can be modified via the Settings Page after deployment. Environment variables serve as initial defaults only.
Storage Configuration
Feature Flags
We recommend setting CACHE_STORAGE_MODE to database to reduce deployment complexity without additional S3 cache configuration.
Secrets (Encrypted)
These sensitive values must be configured as Cloudflare Workers Secrets, entered via CLI during deployment or set in advance.
Authentication
Cloudflare Workers does not support raw TCP SMTP. Email verification is handled by the MailPort sending service:
- Deploy MailPort, create a sender, and configure a delivery method (SMTP / HTTP API / Outlook or Gmail OAuth)
- Rin blog receives a verification code request and calls the endpoint from
EMAIL_SEND_URLS, authenticating withAuthorization: Bearer <EMAIL_SEND_KEYS> - Allowed recipient domains are managed in the MailPort sender configuration
EMAIL_SEND_URLS and EMAIL_SEND_KEYS are matched one-to-one in order and polled: if the first endpoint fails, the next one is tried; an error is raised only when all of them fail.
When EMAIL_SEND_URLS is not set, Rin falls back to the legacy EMAIL_RESEND_URL / EMAIL_RESEND_PASS (Rin-Email project).
Format
EMAIL_SEND_URLS is a JSON array of send URLs; each element is a MailPort sender's full send endpoint, shaped like https://<your-domain>/api/<sender-id>/send. EMAIL_SEND_KEYS holds the matching API keys and can also be a JSON array.
With a single sender, EMAIL_SEND_KEYS may be a plain string, no array brackets needed:
With multiple senders that each have their own key, the two arrays are matched by index:
With multiple senders sharing one key, write a single key that is applied to every endpoint:
When EMAIL_SEND_KEYS provides multiple values, the count must match EMAIL_SEND_URLS (or provide a single shared key); a mismatch fails at send time.
The self-service friend-link flow (apply / modify / delete via email) requires a captcha check on the applicant's first email to prevent automated abuse:
- The applicant sends "友链申请 / 友链修改 / 友链删除" (apply / modify / delete) to the receiving address
- Rin generates a captcha image (4 characters with noise lines and dots) and sends it as an inline image to the applicant
- The applicant replies in a new email containing only those 4 characters
- After the captcha passes, the normal JSON template flow continues
This relies on MailPort's inline-image support and requires no new environment variables — it reuses EMAIL_SEND_URLS + EMAIL_SEND_KEYS. The legacy Rin-Email relay has no inline-image support; if it is still in use, the captcha step is skipped automatically.
You must configure at least one of the following authentication methods:
- GitHub OAuth (
RIN_GITHUB_CLIENT_ID+RIN_GITHUB_CLIENT_SECRET) - Gitee OAuth (
RIN_GITEE_CLIENT_ID+RIN_GITEE_CLIENT_SECRET) - QQ Login (
RIN_QQ_TOKEN) - WeChat Login (
RIN_WECHAT_APPID+RIN_WECHAT_APPKEY) - Email Verification Code Login (
EMAIL_SEND_URLS+EMAIL_SEND_KEYS, or the legacyEMAIL_RESEND_URL+EMAIL_RESEND_PASS) - Username/Password (
ADMIN_USERNAME+ADMIN_PASSWORD)
Otherwise you cannot access the admin panel.
The QQ login callback URL is fixed to https://<your-domain>/api/user/xinyueqq/callback. You must configure the same callback URL for the token in Xinyue. The path is hardcoded in the code, no env var needed.
S3 Storage Credentials
When CACHE_STORAGE_MODE=database, S3 storage credentials are optional and only needed for image uploads.
Cloudflare Bindings (Not Environment Variables)
The following are Cloudflare Worker bindings configured in wrangler.toml, not environment variables:
GitHub Actions Variables
When using GitHub Actions for automated deployment, configure these in your Repository settings:
Repository Variables (Settings → Secrets and variables → Variables)
Repository Secrets (Settings → Secrets and variables → Secrets)
Local Development Environment
For local development, use .env file (see .env.example):
Minimal Deployment Checklist
Username/Password Login Only (Minimal Config)
Full Configuration (All Features)
Includes site config, all OAuth providers, email login, S3 storage, webhook, and RSS.
FAQ
Q: Do I need S3 config when using CACHE_STORAGE_MODE=database?
No. database mode stores cache in D1 database without S3/R2. However, S3 config is still required if you need image uploads.
Q: Can I enable multiple login methods simultaneously?
Yes. Configure credentials for multiple methods and the frontend will display corresponding login buttons automatically.
Q: How to set up email verification code login?
Email verification is handled by the MailPort sending service:
- Deploy MailPort, create a sender, and configure a delivery method (SMTP / HTTP API / Outlook or Gmail OAuth)
- Generate an API key on the MailPort sender page, and configure allowed recipient domains as needed
- In your Cloudflare Worker, configure:
EMAIL_SEND_URLS= the full send endpoint(s) of your MailPort sender (JSON array, multiple allowed)EMAIL_SEND_KEYS= the matching API key(s), paired with the endpoints in order
EMAIL_SEND_URLS and EMAIL_SEND_KEYS are polled in order: if the first endpoint fails, the next one is tried; an error is raised only when all of them fail.
When these two variables are not set, Rin falls back to the legacy EMAIL_RESEND_URL / EMAIL_RESEND_PASS (Rin-Email).
Q: What JSON format do EMAIL_SEND_URLS and EMAIL_SEND_KEYS use?
EMAIL_SEND_URLS is a JSON array of send URLs, each shaped like https://<your-domain>/api/<sender-id>/send. EMAIL_SEND_KEYS holds the keys matched with them in order.
With a single sender, the key may be a plain string:
With multiple senders that each have their own key, the arrays are matched by index:
With multiple senders sharing one key, write a single key:
The number of keys must match the number of URLs, or provide a single shared key; a mismatch fails at send time.
Q: How to restrict allowed email domains?
Add the allowed domains to the "allowed recipient domains" list in your MailPort sender configuration. Only recipients on those domains will be delivered to.
Leave the list empty to allow all domains.
Q: Which delivery methods does MailPort support?
MailPort supports the following delivery methods:
- SMTP: any SMTP provider (163 Mail, QQ Mail, Gmail, etc.)
- HTTP API: forward to a custom HTTP endpoint
- Outlook OAuth2 / Gmail OAuth2: send without app passwords
See the MailPort project documentation.