Mini Program Configuration Guide
This guide will help you complete the WeChat Mini Program backend configuration, including domain requirements, business domain configuration, and verification process.
Prerequisites
Domain Requirements
Before starting configuration, ensure your domain meets the following conditions:
- ✅ Domain must have ICP filing
- ✅ Newly filed domains require 24 hours waiting period before configuration
- ✅ Domain format: Only supports English letters (uppercase and lowercase), numbers, and
- - ❌ IP addresses are not supported
- ❌ Port numbers are not supported (e.g.,
domain.com:8080) - ✅ HTTPS protocol is required
Examples:
- ✅ Correct:
h5.example.com,app.example.com - ❌ Incorrect:
192.168.1.1,example.com:8080,http://example.com
Server Environment
Assumes you have:
- Web server (Nginx, Node.js, or other)
- Configured HTTPS/SSL certificate
- Public domain name
If you haven't configured the server yet, please refer to Server Deployment Configuration first.
WeChat Mini Program Backend Configuration Process
Login to WeChat Official Accounts Platform
- Visit WeChat Official Accounts Platform: https://mp.weixin.qq.com/
- Scan with administrator WeChat to login
- Navigate to: Development → Development Settings → Business Domains
📖 Refer to WeChat Official Configuration Documentation
Download Verification File
Steps
- Click "Add" or "Edit" in the "Business Domains" configuration area
- Enter your H5 domain (e.g.,
h5.example.com) - You will be prompted to download a verification file
- Download the file locally
Verification File Description
- Filename Pattern: Pure random string +
.txtsuffix- Example:
a1b2c3d4e5f6.txt,9f8e7d6c5b4a.txt - Filename has no fixed prefix, just a random string
- Each domain has a unique verification file
- Example:
- File Content: A random string (do not modify)
- File Purpose: Proves you control this domain
Verification Mechanism
WeChat verification process when configuring business domains:
┌─────────────┐ ┌──────────────┐ ┌─────────────┐
│ WeChat │ HTTPS │ Your │ Return │ Verification│
│ Server │ ──────>│ Server │ ──────>│ File │
│ Send Request │ GET │ Nginx/Nodejs │ File │ Content │
└─────────────┘ └──────────────┘ └─────────────┘
Request URL: https://h5.example.com/a1b2c3d4e5f6.txt (random string)
Verification Rules:
- WeChat makes an HTTPS GET request to:
https://yourdomain.com/randomstring.txt(e.g.,a1b2c3d4e5f6.txt) - Server must return 200 status code and correct file content
- After successful verification, the domain can be saved to the business domain list
The verification file must be accessible via HTTPS on the public internet. Before verifying in WeChat backend, you need to deploy the file to the server first. Please refer to Nginx Configuration or Node.js Configuration to complete file deployment.
Deployment Verification
Verify Verification File is Accessible
Method 1: Browser Access
Enter in browser address bar (replace a1b2c3d4e5f6.txt with your actual filename):
https://h5.example.com/a1b2c3d4e5f6.txt
Expected Result:
- Page displays a random string (verification file content)
- Status code is 200
- No 404 or 403 errors
Method 2: Use curl Command for Verification
# Basic verification (replace with your actual filename)
curl https://h5.example.com/a1b2c3d4e5f6.txt
# View detailed HTTP response headers
curl -I https://h5.example.com/a1b2c3d4e5f6.txt
# Expected output:
# HTTP/2 200
# content-type: text/plain
# ...
WeChat Backend Verification
After completing server configuration, return to WeChat Official Accounts Platform:
- On the "Business Domains" configuration page
- Confirm the domain is filled in:
h5.example.com - Click "Save" button
- Wait for WeChat server verification (usually a few seconds)
Verification Success Message:
✅ Verification successful
Domain has been added to business domain list
Verification Failure Message:
❌ Unable to access verification file
Please check if file is uploaded to domain root directory
If verification fails, please refer to Troubleshooting - Verification File Access Failed.
Test WebView in Mini Program
Using WebView in Mini Program Page
WXML Code:
<!-- pages/webview/webview.wxml -->
<web-view src="https://h5.example.com"></web-view>
JSON Configuration:
{
"navigationBarTitleText": "H5 Page",
"enablePullDownRefresh": false
}
Developer Tools Testing
- Open WeChat Developer Tools
- Preview WebView page in simulator
- Check if H5 page loads normally
Developer tools may not strictly validate domains, real device testing is recommended.
Real Device Testing (Important)
- Click the "Preview" button in developer tools
- Scan with mobile WeChat
- Test if WebView displays normally on real device
Common Issues:
- If white screen appears, check if domain configuration is successful
- If "Unable to open webpage" appears, check if HTTPS certificate is valid
After completing Mini Program configuration, you can:
- Learn how to implement H5 and Mini Program Communication
- View Common Issues Troubleshooting