Skip to content

Commit c8a9873

Browse files
committed
chore: send cookie when requesting chatgpt accesstoken
1 parent 54fcc74 commit c8a9873

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/background/index.mjs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,16 @@ async function getChatGptAccessToken() {
4141
if (userConfig.accessToken) {
4242
return userConfig.accessToken
4343
} else {
44-
const resp = await fetch('https://chat.openai.com/api/auth/session')
44+
const cookie = (await Browser.cookies.getAll({ url: 'https://chat.openai.com/' }))
45+
.map((cookie) => {
46+
return `${cookie.name}=${cookie.value}`
47+
})
48+
.join('; ')
49+
const resp = await fetch('https://chat.openai.com/api/auth/session', {
50+
headers: {
51+
Cookie: cookie,
52+
},
53+
})
4554
if (resp.status === 403) {
4655
throw new Error('CLOUDFLARE')
4756
}

0 commit comments

Comments
 (0)