Skip to content

Commit

Permalink
cors2
Browse files Browse the repository at this point in the history
  • Loading branch information
vjnvisakh-jtc committed Mar 18, 2024
1 parent b421d40 commit 3badb39
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions netlify/functions/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@ import type { Context } from '@netlify/functions';
import { getQuoteFromNinja } from './ninja';
import { getQuoteFromGemini } from './gemini';

const headers = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': 'Content-Type',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE'
};

const quote = async (req: Request, context: Context) => {
let data;

if (req.method === 'OPTIONS') {
return {
statusCode: 200,
headers,
body: 'OPTIONS'
};
const res = new Response();

res.headers.set("Access-Control-Allow-Origin", "*");
res.headers.append("Access-Control-Allow-Headers", "*");
res.headers.append("Access-Control-Allow-Methods", "*");

return res;
}

if (Math.random() < 0.5) {
Expand Down

0 comments on commit 3badb39

Please sign in to comment.