feat: allow the embedding in websites to customize sys.user_id (#16062)

This commit is contained in:
Panpan
2025-03-31 18:55:42 +08:00
committed by GitHub
parent 6cf258a809
commit 24b1a625b3
7 changed files with 83 additions and 24 deletions

View File

@@ -262,8 +262,9 @@ export const textToAudioStream = (url: string, isPublicAPI: boolean, header: { c
return (getAction('post', !isPublicAPI))(url, { body, header }, { needAllResponseContent: true })
}
export const fetchAccessToken = async (appCode: string) => {
export const fetchAccessToken = async (appCode: string, userId?: string) => {
const headers = new Headers()
headers.append('X-App-Code', appCode)
return get('/passport', { headers }) as Promise<{ access_token: string }>
const url = userId ? `/passport?user_id=${encodeURIComponent(userId)}` : '/passport'
return get(url, { headers }) as Promise<{ access_token: string }>
}