From 440c15e969cb2432cf8a551500ab66034507cac7 Mon Sep 17 00:00:00 2001 From: Pine Date: Tue, 25 Aug 2026 16:32:27 +0800 Subject: [PATCH] =?UTF-8?q?feat(auth):=20=E6=9D=A5=E6=BA=90=E4=B8=8A?= =?UTF-8?q?=E6=8A=A5=20X-Client(web/miniprogram)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - website fetch 带 X-Client:web; miniprogram 统一请求带 X-Client:miniprogram - server-core /auth 据此识别 source, 零推断(与 desktop 端对应) --- miniprogram/src/utils/api.js | 2 +- website/src/services/auth.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/miniprogram/src/utils/api.js b/miniprogram/src/utils/api.js index efc319f..970d31f 100644 --- a/miniprogram/src/utils/api.js +++ b/miniprogram/src/utils/api.js @@ -12,7 +12,7 @@ const API_BASE = 'https://opc.pinesound.cn'; // 云超服 FastAPI 后端(备 */ export function request(method, path, data = {}, withAuth = false) { return new Promise((resolve, reject) => { - const header = { 'Content-Type': 'application/json' }; + const header = { 'Content-Type': 'application/json', 'X-Client': 'miniprogram' }; if (withAuth) { const token = Taro.getStorageSync('pine_token'); if (token) header.Authorization = `Bearer ${token}`; diff --git a/website/src/services/auth.js b/website/src/services/auth.js index dc85080..90421eb 100644 --- a/website/src/services/auth.js +++ b/website/src/services/auth.js @@ -24,7 +24,7 @@ export async function sendCode(phone) { try { res = await fetch(`${API_BASE}/api/auth/send-code`, { method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers: { 'Content-Type': 'application/json', 'X-Client': 'web' }, body: JSON.stringify({ phone }) }); } catch { @@ -40,7 +40,7 @@ export async function phoneLogin(phone, code) { try { res = await fetch(`${API_BASE}/api/auth/phone-login`, { method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers: { 'Content-Type': 'application/json', 'X-Client': 'web' }, body: JSON.stringify({ phone, code }) }); } catch { @@ -58,7 +58,7 @@ export async function login(username, password) { try { res = await fetch(`${API_BASE}/api/auth/login`, { method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers: { 'Content-Type': 'application/json', 'X-Client': 'web' }, body: JSON.stringify({ username, password }) }); } catch {