Skip to content

Commit

Permalink
feat(nx-dev): move openai call to edge function
Browse files Browse the repository at this point in the history
  • Loading branch information
mandarini committed Aug 21, 2023
1 parent 078cf9a commit 1c51c3f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions nx-dev/nx-dev/pages/api/openai.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { NextRequest } from 'next/server';

export const config = {
runtime: 'edge',
};

export default function handler(request: NextRequest) {
const { searchParams } = new URL(request.url);

return new Response(
JSON.stringify({
body: 'Hello world!',
query: searchParams.get('query'),
cookies: request.cookies,
}),
{
status: 200,
headers: {
'content-type': 'application/json',
},
}
);
}

0 comments on commit 1c51c3f

Please sign in to comment.