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
commit 24b1a625b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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 }>
}