fix: 微信 OAuth 配置改用 fetch 避免 OPTIONS 405
All checks were successful
Build and Deploy Front / deploy (push) Successful in 9m16s
All checks were successful
Build and Deploy Front / deploy (push) Successful in 9m16s
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
6788de9016
commit
d52e10b09e
@ -9,6 +9,7 @@ import type {
|
||||
WxFollowQrcodeResult,
|
||||
WxLoginQrcodeResult,
|
||||
WxLoginResult,
|
||||
WxLoginStatusResult,
|
||||
WxOAuthConfigResult,
|
||||
} from './types';
|
||||
|
||||
@ -48,11 +49,14 @@ export async function getFollowQrcode(): Promise<WxFollowQrcodeResult> {
|
||||
|
||||
/** H5 网页授权:从其他配置 wechat_mp 读取 AppId / OAuth 回调根 */
|
||||
export async function getWeChatOAuthConfig(): Promise<WxOAuthConfigResult> {
|
||||
// 不带默认 Content-Type,避免无必要的 CORS 预检(OPTIONS 易被网关/路由判 405)
|
||||
const res = await axiosInstance.get(omsUrl('/wechat/oauth/config'), {
|
||||
headers: { 'Content-Type': undefined as unknown as string },
|
||||
});
|
||||
const data = unwrapOrSelf<WxOAuthConfigResult & Record<string, unknown>>(res.data);
|
||||
// 用 fetch 发简单 GET,避免 axios 默认 Content-Type 触发 OPTIONS(易 405)
|
||||
const url = omsUrl('/wechat/oauth/config');
|
||||
const res = await fetch(url, { method: 'GET' });
|
||||
if (!res.ok) {
|
||||
throw new Error(`获取微信 OAuth 配置失败(${res.status})`);
|
||||
}
|
||||
const body = await res.json();
|
||||
const data = unwrapOrSelf<WxOAuthConfigResult & Record<string, unknown>>(body);
|
||||
const appId = String(data.appId ?? data.AppId ?? '').trim();
|
||||
const oauthRedirectBase = String(
|
||||
data.oauthRedirectBase ?? data.OAuthRedirectBase ?? '',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user