fix(mini-user): use USER_MINI for WeChat SDK so OAuth token persists
CI / verify (pull_request) Has been cancelled

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-15 20:22:37 +08:00
parent acc5b78471
commit 372c29bc3a
2 changed files with 9 additions and 8 deletions
+2 -3
View File
@@ -1,9 +1,8 @@
import Taro from '@tarojs/taro';
import { getWechatLocationDetailed } from '@dukang/weixin-sdk';
import { API_BASE, getToken, request } from './api';
import { API_BASE, CLIENT_APP, getToken, request } from './api';
import { DEFAULT_REGION, regionFromGeo, type RegionSelection } from './region-data';
import { FALLBACK_CITY_CODE } from './product-images';
import { ClientApp } from '@dukang/shared-types';
export const GPS_CITY_STORAGE_KEY = 'dukang_gps_city';
@@ -123,7 +122,7 @@ function getMiniLocation(): Promise<Taro.getLocation.SuccessCallbackResult> {
async function resolveViaH5Jssdk(): Promise<ResolvedUserCity | null> {
const outcome = await getWechatLocationDetailed({
apiBase: API_BASE,
clientApp: ClientApp.USER_H5,
clientApp: CLIENT_APP,
getAccessToken: () => getToken() || null,
});
+7 -5
View File
@@ -1,14 +1,16 @@
import { ClientApp } from '@dukang/shared-types';
import { createWeixinSdk, isWechatEnv } from '@dukang/weixin-sdk';
import { API_BASE, getToken } from './api';
import { API_BASE, CLIENT_APP, getToken } from './api';
/**
* H5 公众号内 JSSDK(分享 / 定位等)走 USER_H5 对应的公众号 appId
* 小程序原生能力不经此门面。
* H5 公众号内 JSSDK(分享 / OAuth / 支付)须与业务 API 使用同一 X-Client-App
* mini-user 全端(含 H5 产物)统一为 USER_MINI,否则 OAuth 登录签发的 JWT
* 与本地请求头 USER_MINI 不匹配 → 401 清登录 → 反复拉起微信授权。
*
* (历史 h5-user 仍用 USER_H5;公众号能力由后端凭证配置,不依赖该 ClientApp 标签。)
*/
export const weixinSdk = createWeixinSdk({
apiBase: API_BASE,
clientApp: process.env.TARO_ENV === 'h5' ? ClientApp.USER_H5 : ClientApp.USER_MINI,
clientApp: CLIENT_APP,
getAccessToken: () => getToken() || null,
});