mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 12:15:24 +02:00
fix vercel load errors
This commit is contained in:
+3
-15
@@ -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' });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user