2026-02-02 09:13:05 +01:00
|
|
|
import type { VercelRequest, VercelResponse } from '@vercel/node';
|
|
|
|
|
|
|
|
|
|
// PANEU Stock from Dropbox (using dl=1 for direct download)
|
2026-04-27 12:08:10 +02:00
|
|
|
const PANEU_STOCK_DROPBOX_URL = "https://www.dropbox.com/scl/fi/85pijr1wczgclsdv3izzd/PANEU-Stock.xlsx?rlkey=4bkv1v5ha6sjhyujgxivusnn8&st=taapf9s1&dl=1";
|
2026-02-02 09:13:05 +01:00
|
|
|
|
|
|
|
|
export default async function handler(req: VercelRequest, res: VercelResponse) {
|
|
|
|
|
// CORS headers
|
|
|
|
|
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
|
|
|
res.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');
|
|
|
|
|
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
|
|
|
|
|
|
|
|
|
|
if (req.method === 'OPTIONS') {
|
|
|
|
|
return res.status(200).end();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
console.log('[fetch-paneu-stock] Fetching PANEU Stock from Dropbox...');
|
|
|
|
|
const response = await fetch(PANEU_STOCK_DROPBOX_URL, {
|
|
|
|
|
cache: 'no-store',
|
|
|
|
|
headers: {
|
|
|
|
|
'Pragma': 'no-cache',
|
|
|
|
|
'Cache-Control': 'no-cache'
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!response.ok) {
|
|
|
|
|
throw new Error(`Dropbox responded with ${response.status}`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const buffer = await response.arrayBuffer();
|
|
|
|
|
console.log('[fetch-paneu-stock] Successfully fetched PANEU Stock Excel, size:', buffer.byteLength);
|
|
|
|
|
|
|
|
|
|
res.setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
|
|
|
|
res.status(200).send(Buffer.from(buffer));
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
console.error('[fetch-paneu-stock] Error:', error);
|
|
|
|
|
res.status(500).json({ error: error.message });
|
|
|
|
|
}
|
|
|
|
|
}
|