File size: 853 Bytes
f2c621a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
'use server'
import { NextApiRequest, NextApiResponse } from 'next'
import { fetch, debug } from '@/lib/isomorphic'
import { createHeaders } from '@/lib/utils'
// const API_ENDPOINT = 'https://www.bing.com/turing/conversation/create'
const API_ENDPOINT = 'https://edgeservices.bing.com/edgesvc/turing/conversation/create';
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
try {
const headers = createHeaders(req.cookies)
res.writeHead(200, {
'Content-Type': 'application/json',
})
debug('headers', headers)
const response = await fetch(API_ENDPOINT, { method: 'GET', headers })
.then((res) => res.text())
res.end(response)
} catch (e) {
return res.end(JSON.stringify({
result: {
value: 'UnauthorizedRequest',
message: `${e}`
}
}))
}
}
|