Backstage: WeChat official account page, with the frame of nuxt.js
Problem: When iphone enters the page for the first time, it prompts: config:signature is invalid, which means the signature is invalid. After refreshing the current page, the signature passed (config: ok). However, the Android phone has always been normal (configuration: ok).
Wechat sharing process:
Wechat document
Step 1: Set the secure domain name of JS interface in the official WeChat account.
Step 2: Import the js file.
Step 3: Obtain the signature: pass in the url of the current page (the URL of the current webpage, excluding # and its subsequent parts) as a parameter, and request the back-end interface to obtain the signature.
Step 4: All pages that need to use JS-SDK must be injected with configuration information first, and the signature information (AppId, signature generation timestamp, signature generation and signature random string) obtained in step 3 is passed into wx.config to complete configuration and start debugging mode: debug: true.
At this time, when you open it with an Android phone, you will be prompted: config: ok, everything is fine.
Here comes the question:
At this time, I opened it with iphone, and the prompt: config: signature is invalid. After refreshing the page, you will be prompted: config: ok, ok again? What the hell?
Step 3, print out the URL of the current page:/share/
The address to enter this page is:
Click the actual browser is:
Because the two addresses are inconsistent, the actual address of the browser after refreshing the page is: /share/ (there is a "/"at the end of the url after refreshing the page). At this point, the two addresses are exactly the same, so sign config: ok after refreshing the page.
Solution:
The simplest and rudest solution is to add "/"at the end when entering the page: