fix: Fehler beim Setzen der Referenzkurve in Development behoben
- überflüssiger fetch auf /CPL?KTR... in Development entfernt - Fehler-Alert durch 404-Seite bei Embedded-Link im Dev gefixt - Referenzkurve wird jetzt in Dev nur lokal gespeichert und per API aktualisiert
This commit is contained in:
33
pages/api/cpl/updateTdrReferenceCurveAPIHandler.ts
Normal file
33
pages/api/cpl/updateTdrReferenceCurveAPIHandler.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
// /pages/api/cpl/updateTdrReferenceCurveAPIHandler.ts
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import path from "path";
|
||||
import { promises as fs } from "fs";
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse
|
||||
) {
|
||||
if (req.method !== "POST") {
|
||||
return res.status(405).json({ error: "Method not allowed" });
|
||||
}
|
||||
|
||||
const { slot, data } = req.body;
|
||||
|
||||
if (!slot || !data) {
|
||||
return res.status(400).json({ error: "Missing slot or data" });
|
||||
}
|
||||
|
||||
const filePath = path.join(
|
||||
process.cwd(),
|
||||
"apiMockData",
|
||||
"tdr-reference-curves",
|
||||
`slot${slot}.json`
|
||||
);
|
||||
|
||||
try {
|
||||
await fs.writeFile(filePath, JSON.stringify(data, null, 2), "utf-8");
|
||||
res.status(200).json({ success: true });
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: "Failed to save file" });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user