Overview
As per the WeChat mini-program development requirements, the developer needs to configure a list of domains in advance for each mini-program before they can be accessed through the mini program. The mini-program can only communicate with the specified domains over the network.
Process of adding the domain to WeChat mini-program
- Configure the domain name on Mini Program Console > Settings > Development Settings > Server Domain Name.
- The domain should be supporting HTTPS
- While adding the domain, WeChat requires the domain to be verified with a text file that can be downloaded from the configuration page. You can read more from about the processes from the link here.
- The content of the verification file is a simple string and should not be in HTML format. This process is similar to whilelist a firewall.
- Once it is configured correctly, the domain can be saved on the popup screen above.
Example of how to Examine the Verification file
If the domain you wish to save is https://test.com/ and the downloaded verification file is AbC.txt, you need to ensure that https://test.com/AbC.txt can be accessed. **The URL is case sensitive, please make sure you are using the exactly the same case as the filename.
The content of the verification file is generally non-HTML data, it should be simple strings. If the content of the downloaded verification file is in HTML format, log out from the WeChat platform. Log in to the platform again to download the verification file.
Use a 4G network to try to access the link and confirm that the server itself is not intercepting the request (this is a commonly used process on servers with whitelists or firewalls, which needs to be confirmed by the developer)
Use curl to test the link to ensure that curl can access the link normally, and the content of the curl is the content of the verification file.
Use time curl https://test.com/abc.txt to check the link time. It is recommended to take less than 1s.