错误提示: config:fail,invalid signature
正确的方式:
- 前端显示的路径,如果存在中文参数,那么需要 使用
encodeURIComponent对中文字符串进行编码
假如有这样子的 url
const str = `http://localhost:5173/detail.html?path=/api/image/p2904477111.webp&title=飞驰人生2®ion=中国大陆&genres=剧情喜剧运动&director=韩寒`;
需要改成
const title = encodeURIComponent("飞驰人生2");
const region = encodeURIComponent("中国大陆");
const genres = encodeURIComponent("剧情喜剧运动");
const director = encodeURIComponent("韩寒");
const str = `http://localhost:5173/detail.html?path=/api/image/p2904477111.webp&title=${title}®ion=${region}&genres=${genres}&director=${director}`;
- 前端发送给后端的参数(一般 post 请求) 内容如下, 后端无需
decodeURIComponent
{
"url": "https://docs.ffffee.com/wechat/mobile/detail.html?path=/api/image/p2903145026.webp&title=%E7%AC%AC%E4%BA%8C%E5%8D%81%E6%9D%A1®ion=%E4%B8%AD%E5%9B%BD%E5%A4%A7%E9%99%86&genres=%E5%89%A7%E6%83%85%E5%96%9C%E5%89%A7%E5%AE%B6%E5%BA%AD&director=%E5%BC%A0%E8%89%BA%E8%B0%8B"
}