Skip to content

Commit

Permalink
try for public APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
lovehunter9 committed Jan 7, 2025
1 parent 77f0e17 commit 2986b73
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions web/service/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,9 @@ const baseFetch = <T>(
getAbortController(abortController)
options.signal = abortController.signal
}
//const accessToken = getAccessToken(isPublicAPI)
//options.headers.set('Authorization', `Bearer ${accessToken}`)
// try for public APIs
const accessToken = getAccessToken(isPublicAPI)
options.headers.set('Authorization', `Bearer ${accessToken}`)

if (deleteContentType) {
options.headers.delete('Content-Type')
Expand Down Expand Up @@ -413,12 +414,14 @@ const baseFetch = <T>(

export const upload = (options: any, isPublicAPI?: boolean, url?: string, searchParams?: string): Promise<any> => {
const urlPrefix = isPublicAPI ? PUBLIC_API_PREFIX : API_PREFIX
//const token = getAccessToken(isPublicAPI)
// try for public APIs
const token = getAccessToken(isPublicAPI)
const defaultOptions = {
method: 'POST',
url: (url ? `${urlPrefix}${url}` : `${urlPrefix}/files/upload`) + (searchParams || ''),
headers: {
//Authorization: `Bearer ${token}`,
// try for public APIs
Authorization: `Bearer ${token}`,
},
data: {},
}
Expand Down Expand Up @@ -500,8 +503,9 @@ export const ssePost = (
if (body)
options.body = JSON.stringify(body)

//const accessToken = getAccessToken(isPublicAPI)
//options.headers.set('Authorization', `Bearer ${accessToken}`)
// try for public APIs
const accessToken = getAccessToken(isPublicAPI)
options.headers.set('Authorization', `Bearer ${accessToken}`)

globalThis.fetch(urlWithPrefix, options as RequestInit)
.then((res) => {
Expand Down

0 comments on commit 2986b73

Please sign in to comment.