Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 28, 2025

微信云托管环境中 api.weixin.qq.com 被解析为内网地址,无法使用 HTTPS,需改用 HTTP 协议访问。

更改内容

  • WxMaConfig 接口

    • 新增 isUseWxCloudRun() / setUseWxCloudRun() 配置方法
    • 新增 getEffectiveApiHostUrl() 默认方法统一处理 API URL 替换逻辑
    • 新增 DEFAULT_API_HOST_URLCLOUD_RUN_API_HOST_URL 常量
  • WxMaDefaultConfigImpl

    • 实现 useWxCloudRun 字段及其访问方法
  • HTTP 客户端实现类

    • 简化 BaseWxMaServiceImplWxMaServiceHttpClientImplWxMaServiceOkHttpImplWxMaServiceJoddHttpImpl 中的 URL 处理逻辑

使用方式

WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
config.setUseWxCloudRun(true);

优先级

自定义 apiHostUrl > useWxCloudRun > 默认 HTTPS 地址

参考

https://developers.weixin.qq.com/miniprogram/dev/wxcloudservice/wxcloudrun/src/guide/weixin/open.html

Original prompt

This section details on the original issue you should resolve

<issue_title>希望支持微信云托管</issue_title>
<issue_description>

简要描述

当使用微信云托管时,微信会将api.weixin.qq.com 解析为内网地址,导致无法使用https,希望增加一个配置,如果是类似场景,就直接使用http进行访问

官方文档地址

https://developers.weixin.qq.com/miniprogram/dev/wxcloudservice/wxcloudrun/src/guide/weixin/open.html
</issue_description>

Comments on the Issue (you are @copilot in this section)

@binarywang 欢迎直接提交PR代码来支持,最好是经过验证的代码,谢谢

Custom agent used: 自定义的
需要用中文


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Nov 28, 2025
Copilot AI changed the title [WIP] Add support for WeChat cloud hosting configuration feat(miniapp): 添加微信云托管支持 Nov 28, 2025
Copilot AI requested a review from binarywang November 28, 2025 04:16
@binarywang binarywang marked this pull request as ready for review November 28, 2025 05:51
@binarywang binarywang merged commit 155f3f7 into develop Nov 28, 2025
1 check failed
@binarywang binarywang added this to the 4.7.9 milestone Nov 28, 2025
@binarywang binarywang deleted the copilot/support-wechat-cloud-hosting branch November 28, 2025 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

希望支持微信云托管

2 participants