File size: 894 Bytes
d6c14d2 |
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 |
'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)
debug('headers', headers)
const response = await fetch(API_ENDPOINT, { method: 'GET', headers, redirect: 'error', mode: 'cors', credentials: 'include' })
.then((res) => res.text())
res.writeHead(200, {
'Content-Type': 'application/json',
})
res.end(response)
} catch (e) {
return res.json({
result: {
value: 'UnauthorizedRequest',
message: `${e}`
}
})
}
}
|