chore: send cookie when requesting chatgpt accesstoken

This commit is contained in:
josc146
2023-04-20 22:30:59 +08:00
parent 7bd9f064d7
commit 7aa2dc8cfe
+10 -1
View File
@@ -41,7 +41,16 @@ async function getChatGptAccessToken() {
if (userConfig.accessToken) {
return userConfig.accessToken
} else {
const resp = await fetch('https://chat.openai.com/api/auth/session')
const cookie = (await Browser.cookies.getAll({ url: 'https://chat.openai.com/' }))
.map((cookie) => {
return `${cookie.name}=${cookie.value}`
})
.join('; ')
const resp = await fetch('https://chat.openai.com/api/auth/session', {
headers: {
Cookie: cookie,
},
})
if (resp.status === 403) {
throw new Error('CLOUDFLARE')
}