fix(wechat): 公众号验签接口始终返回 HTTP 200,避免 BusinessException 导致非 200
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
1b8a5af807
commit
d168a21e96
@ -15,9 +15,10 @@ internal static class WeChatMpCallbackSupport
|
||||
string? nonce,
|
||||
string? echostr)
|
||||
{
|
||||
// 微信服务器要求 HTTP 200 + 纯文本 echostr,不可抛 BusinessException(会变成 JSON 非 200)
|
||||
if (string.IsNullOrWhiteSpace(options.Value.Token))
|
||||
{
|
||||
throw new BusinessException("未配置微信公众号 Token");
|
||||
return PlainText("error");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(signature)
|
||||
@ -90,8 +91,8 @@ internal static class WeChatMpCallbackSupport
|
||||
}
|
||||
|
||||
private static ContentResult PlainText(string content) =>
|
||||
new() { Content = content, ContentType = "text/plain; charset=utf-8" };
|
||||
new() { Content = content, ContentType = "text/plain; charset=utf-8", StatusCode = StatusCodes.Status200OK };
|
||||
|
||||
private static ContentResult Xml(string content) =>
|
||||
new() { Content = content, ContentType = "application/xml; charset=utf-8" };
|
||||
new() { Content = content, ContentType = "application/xml; charset=utf-8", StatusCode = StatusCodes.Status200OK };
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user