mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-09-04 23:17:34 +08:00
feat: add daily request limit and refactor access control (#759)
- Add daily request limit per IP in blacklist settings (1-1,000,000/day) - Refactor access control logic: merge blacklist and rate limit checks - Remove RATE_LIMIT_API_DAILY_REQUESTS env var, use database config instead - Move x-custom-auth check earlier in middleware chain - Add comprehensive English documentation (31 new guide pages) - Improve code structure and error handling 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
# Cloudflare Workers Backend
|
||||
|
||||
> [!warning] Note
|
||||
> The `worker.dev` domain is not accessible in China, please use a custom domain.
|
||||
|
||||
1. Click `Compute (Workers)` -> `Workers & Pages` -> `Create`
|
||||
|
||||

|
||||
|
||||
2. Select `Worker`, click `Create Worker`, modify the name and then click `Deploy`
|
||||
|
||||

|
||||

|
||||
|
||||
3. Go back to `Workers & Pages`, find the worker you just created, click `Settings` -> `Runtime`, modify `Compatibility flags`, manually add `nodejs_compat`, and the compatibility date also needs to be later than the date shown in the image.
|
||||
|
||||

|
||||
|
||||
4. Download [worker.js](https://github.com/dreamhunter2333/cloudflare_temp_email/releases/latest/download/worker.js)
|
||||
|
||||
5. Go back to `Overview`, find the worker you just created, click `Edit Code`, delete the original file, upload `worker.js`, and click `Deploy`
|
||||
|
||||
> [!NOTE]
|
||||
> To upload, first click Explorer in the left menu,
|
||||
> then right-click in the file list window and find `Upload` in the context menu,
|
||||
> please refer to the screenshots below
|
||||
>
|
||||
> Reference: [issues156](https://github.com/dreamhunter2333/cloudflare_temp_email/issues/156#issuecomment-2079453822)
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
6. Click `Settings` -> `Variables and Secrets`, add variables as shown in the image
|
||||
|
||||

|
||||
|
||||
> [!NOTE] Note
|
||||
> For more variable configuration, please see [Worker Variables Documentation](/en/guide/worker-vars)
|
||||
>
|
||||
> Note that the outermost quotes are not needed for string format variables
|
||||
>
|
||||
> For `USER_ROLES`, please configure in this format: `[{"domains":["awsl.uk","dreamhunter2333.xyz"],"role":"vip","prefix":"vip"},{"domains":["awsl.uk","dreamhunter2333.xyz"],"role":"admin","prefix":""}]`
|
||||
|
||||
Recommended variable list
|
||||
|
||||
| Variable Name | Type | Description | Example |
|
||||
| -------------------------- | ----------- | ---------------------------------------------------------------------- | ------------------------------------ |
|
||||
| `PREFIX` | Text | Default prefix for new email names, can be omitted if no prefix needed | `tmp` |
|
||||
| `DOMAINS` | JSON | All domains for temporary email, supports multiple domains | `["awsl.uk", "dreamhunter2333.xyz"]` |
|
||||
| `JWT_SECRET` | Text/Secret | Secret for generating JWT, JWT is used for login and authentication | `xxx` |
|
||||
| `ADMIN_PASSWORDS` | JSON | Admin console password, console access not allowed if not configured | `["123", "456"]` |
|
||||
| `ENABLE_USER_CREATE_EMAIL` | Text/JSON | Whether to allow users to create emails, not allowed if not configured | `true` |
|
||||
| `ENABLE_USER_DELETE_EMAIL` | Text/JSON | Whether to allow users to delete emails, not allowed if not configured | `true` |
|
||||
|
||||
7. Click `Settings` -> `Bindings`, click `Add Binding`, enter the name as shown, select the D1 database you just created, and click `Add Binding`
|
||||
|
||||
> [!NOTE] Important
|
||||
> Note that the binding name for `D1 Database` here must be `DB`
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
8. Click `Settings` -> `Triggers`, here you can add your own domain, or you can use the automatically generated `*.workers.dev` domain. Record this domain, as it will be needed when deploying the frontend later.
|
||||
|
||||
> [!NOTE]
|
||||
> Open the `worker` `url`, if it displays `OK`, the deployment is successful
|
||||
>
|
||||
> Open `/health_check`, if it displays `OK`, the deployment is successful
|
||||
|
||||

|
||||
|
||||
9. If you want to enable the user registration feature and need to send email verification, you need to create a `KV` cache. You can skip this step if not needed.
|
||||
|
||||
> [!NOTE] Important
|
||||
> If you want to enable the user registration feature and need to send email verification, you need to create a `KV` cache. You can skip this step if not needed.
|
||||
>
|
||||
> Note that the binding name for `KV` here must be `KV`
|
||||
|
||||
Click `Storage & Databases` -> `KV` -> `Create Namespace`, as shown in the image, click `Create Namespace`
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
Then click `Settings` -> `Bindings`, click `Add Binding`, enter the name as shown, select the KV you just created, and click `Add Binding`
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
10. Telegram Bot Configuration
|
||||
|
||||
> [!NOTE]
|
||||
> If you don't need Telegram Bot, you can skip this step
|
||||
|
||||
Please first create a Telegram Bot, then get the `token`, add the `token` to `Variables and Secrets`, variable name: `TELEGRAM_BOT_TOKEN`
|
||||
|
||||
11. If you want to use the scheduled task to clean emails in the admin page, you need to add a scheduled task in `Settings` -> `Trigger Events` -> `Cron Triggers`.
|
||||
|
||||
> [!NOTE]
|
||||
> Select `cron` expression, enter `0 0 * * *` (this expression means run daily at midnight), click `Add` to add. Please adjust this expression according to your needs.
|
||||
Reference in New Issue
Block a user