Files
pbakaus_impeccable/api/download/bundle/[provider].js
T
Paul BakausandClaude Opus 4.5 73a3367e0a Fix: Use standard Vercel serverless function format (req, res)
Response.json() is for Edge Functions, not Node.js serverless functions.
Switched all API handlers to use res.status().json() format which is
the standard for Vercel Node.js functions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 15:00:08 -08:00

29 lines
915 B
JavaScript

import { readFileSync, existsSync } from "fs";
import { join, dirname } from "path";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const PROJECT_ROOT = join(__dirname, "../../..");
export default function handler(req, res) {
try {
const { provider } = req.query;
const distDir = join(PROJECT_ROOT, "dist");
const zipPath = join(distDir, `${provider}.zip`);
if (!existsSync(zipPath)) {
return res.status(404).json({ error: "Bundle not found" });
}
const content = readFileSync(zipPath);
res.setHeader("Content-Type", "application/zip");
res.setHeader("Content-Disposition", `attachment; filename="impeccable-style-${provider}.zip"`);
res.send(content);
} catch (error) {
console.error("Error downloading bundle:", error);
res.status(500).json({ error: error.message });
}
}