A lightweight page to prevent you website load in WeChat browser
中文 | English
Warning: This project is still on early stage. It does not have many tests. Please be careful before using it.
Deploy this webpage before you send your service to users, or use Cloudflare Redirect Rules to display this page automatically.
It will prevent users to open your website directly in WeChat browser and show following page instead. But on other browser, it will redirect to target link automatically.
- Fork this project to your Github account
- Login to Cloudflare Dashboard
- Select Compute & AI - Workers & Pages in the left sidebar
- Click Create an application - Pages on the top right corner
- Select your Github repository and deploy
- Fill in Build command with
pnpm run build - Fill in Build output directory with
dist - Add environment variables in Environment variables (advanced) as needed
- Bind custom domain as needed
| Environment Variable | Description | Default |
|---|---|---|
| BG_URL | Background image URL (recommend length-width ratio 69 : 28) | Random Picture |
| CHECK_HTTPS | Check if target link is using HTTPS | false |
| ALLOW_DOMAINS | Allowed domains for link (empty for all, use ',' to split multiple domains) | all |
| SHOW_GITHUB | Show project link at bottom | true |
| FAVICON_URL | Website favicon URL | |
| HTTPS_AUTO_UPGRADE | Automatically upgrade HTTP protocol to HTTPS | false |
Match Expression:
(http.user_agent contains "MicroMessenger") or (http.user_agent contains "XWEB") or (http.user_agent contains "XWEB")
Dynamic HTTP302 Redirect to:
concat("https://PAGES_DOMAIN/?link=", http.request.full_uri)
| Param | Description | Default |
|---|---|---|
| link | Target link | |
| lang | Display language | Browser default |
| force | Stay on this page and does not redirect on non WeChat browser | false |
Tips: param
forceshould only be used in develop environment.
- pnpm install
- pnpm run dev
