Skip to main content

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
Tip

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

  1. Visit WeChat Official Accounts Platform: https://mp.weixin.qq.com/
  2. Scan with administrator WeChat to login
  3. Navigate to: Development → Development Settings → Business Domains

📖 Refer to WeChat Official Configuration Documentation

Download Verification File

Steps

  1. Click "Add" or "Edit" in the "Business Domains" configuration area
  2. Enter your H5 domain (e.g., h5.example.com)
  3. You will be prompted to download a verification file
  4. Download the file locally

Verification File Description

  • Filename Pattern: Pure random string + .txt suffix
    • Example: a1b2c3d4e5f6.txt, 9f8e7d6c5b4a.txt
    • Filename has no fixed prefix, just a random string
    • Each domain has a unique verification file
  • File Content: A random string (do not modify)
  • File Purpose: Proves you control this domain

WeChat Mini Program Business Domain Configuration Example

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:

  1. WeChat makes an HTTPS GET request to: https://yourdomain.com/randomstring.txt (e.g., a1b2c3d4e5f6.txt)
  2. Server must return 200 status code and correct file content
  3. After successful verification, the domain can be saved to the business domain list
Important

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:

  1. On the "Business Domains" configuration page
  2. Confirm the domain is filled in: h5.example.com
  3. Click "Save" button
  4. 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
Common Issues

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

  1. Open WeChat Developer Tools
  2. Preview WebView page in simulator
  3. Check if H5 page loads normally
Note

Developer tools may not strictly validate domains, real device testing is recommended.

Real Device Testing (Important)

  1. Click the "Preview" button in developer tools
  2. Scan with mobile WeChat
  3. 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
Next Steps

After completing Mini Program configuration, you can: