fix vercel load errors

This commit is contained in:
Christian Vidal Wolf
2026-05-20 13:57:11 +02:00
parent 88dc894050
commit e8d05069f3
8 changed files with 75 additions and 91 deletions
+3 -9
View File
@@ -1,19 +1,13 @@
import { applyCors, isAllowedOrigin } from './_cors.js';
import { createClient } from '@supabase/supabase-js';
const SUPABASE_URL = process.env.SUPABASE_URL || 'https://hwithddwaapyhnfwcesj.supabase.co';
const SUPABASE_KEY = process.env.SUPABASE_SERVICE_KEY || 'sb_publishable_fGXkh0bSrAOqSk2jWKAzSg_NJD9YPCv';
const ALLOWED_ORIGIN = 'https://craze-data-check.vercel.app';
const supabase = createClient(SUPABASE_URL, SUPABASE_KEY);
function setCors(req, res) {
const origin = req.headers.origin;
if (origin === ALLOWED_ORIGIN) {
res.setHeader('Access-Control-Allow-Origin', ALLOWED_ORIGIN);
}
res.setHeader('Access-Control-Allow-Methods', 'POST, OPTIONS');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
res.setHeader('Vary', 'Origin');
applyCors(req, res, 'POST, OPTIONS');
}
export default async function handler(req, res) {
@@ -24,7 +18,7 @@ export default async function handler(req, res) {
}
const origin = req.headers.origin;
if (origin && origin !== ALLOWED_ORIGIN) {
if (origin && !isAllowedOrigin(origin)) {
return res.status(403).json({ error: 'Forbidden' });
}