Skip to content

Commit

Permalink
deploy cors
Browse files Browse the repository at this point in the history
  • Loading branch information
martypdx committed Oct 27, 2023
1 parent 54c86eb commit 068d441
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion supabase/functions/_lib/cors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const corsHeaders = {
export const corsHeaders = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers':
'authorization, x-client-info, apikey, content-type',
Expand Down
5 changes: 4 additions & 1 deletion supabase/functions/_lib/openai.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { LogStdOutStream, OpenAIContentStream } from './streams.ts';
import { corsHeaders } from './cors.ts';

const API_KEY = Deno.env.get('OPENAI_API_KEY');
const COMPLETIONS_URL = 'https://api.openai.com/v1/chat/completions';
Expand Down Expand Up @@ -32,6 +33,7 @@ export async function streamCompletion(
console.log('open AI call failed', text);
return new Response(text, {
headers: {
...corsHeaders,
'content-type': 'application/json',
},
status: status,
Expand All @@ -51,8 +53,9 @@ export async function streamCompletion(

return new Response(stream, {
headers: {
...corsHeaders,
'content-type': 'text/event-stream; charset=utf-8',
// 'x-content-type-options': 'nosniff',
'x-content-type-options': 'nosniff',
},
status: status,
});
Expand Down

0 comments on commit 068d441

Please sign in to comment.