-
Notifications
You must be signed in to change notification settings - Fork 303
/
route.ts
21 lines (18 loc) · 732 Bytes
/
route.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import type { NextRequest } from "next/server";
import { ensureAuth } from "../ensureAuth";
export const runtime = "edge";
export async function POST(request: NextRequest) {
// const d = await ensureAuth(request);
// if (!d) {
// return new Response("Unauthorized", { status: 401 });
// }
const res : {context: string, request: string} = await request.json()
try {
const response = await fetch(`${process.env.BACKEND_BASE_URL}/api/editorai?context=${res.context}&request=${res.request}`);
return new Response(response.body, { status: 200 });
// const result = await response.json();
// return new Response(JSON.stringify(result));
} catch (error) {
return new Response(`Error, ${error}`)
}
}