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 -15
View File
@@ -1,21 +1,9 @@
import { applyCors, isAllowedOrigin } from './_cors.js';
import * as XLSX from 'xlsx';
import { getBcConfig, getBCToken, fetchAllItems, buildWorkbook } from '../bc-runtime.js';
const ALLOWED_ORIGINS = [
'http://localhost:3000',
'http://localhost:4173',
'http://localhost:5173',
'https://craze-data-check.vercel.app',
];
function setCors(req, res) {
const origin = req.headers.origin;
if (origin && ALLOWED_ORIGINS.includes(origin)) {
res.setHeader('Access-Control-Allow-Origin', origin);
}
res.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
res.setHeader('Vary', 'Origin');
applyCors(req, res, 'GET, OPTIONS');
}
export default async function handler(req, res) {
@@ -24,7 +12,7 @@ export default async function handler(req, res) {
if (req.method === 'OPTIONS') return res.status(204).end();
const origin = req.headers.origin;
if (origin && !ALLOWED_ORIGINS.includes(origin)) {
if (origin && !isAllowedOrigin(origin)) {
return res.status(403).json({ error: 'Forbidden' });
}