From d77755a7dd839ac99feb921e7b59fc7f00f45a3b Mon Sep 17 00:00:00 2001 From: Kirigaya <1193466151@qq.com> Date: Thu, 17 Oct 2024 15:19:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E4=BF=9D=E5=AD=98=E6=81=A2?= =?UTF-8?q?=E5=A4=8D=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main.ts b/src/main.ts index 338eccd..7a8c404 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,7 +9,6 @@ import bodyParser from 'body-parser'; import { BSON } from 'bson'; const corsOptions = { - origin: 'http://localhost:8080', // 一些旧版浏览器(如 IE11、各种 SmartTV)在 204 状态下会有问题 optionsSuccessStatus: 200 }; @@ -31,18 +30,17 @@ app.get('/', (req: Request, res: Response) => { app.post('/save-view', async (req: Request, res: Response) => { try { - const { file, payload } = req.body; - console.log(payload); - + const { file, payload } = req.body; const savePath = path.join(rootPath, file); const buffer = BSON.serialize(payload); fs.writeFileSync(savePath, buffer); + res.send('success'); } catch (error) { console.log('error happen in /save-view, ' + error); + res.send('error'); } }) - const PORT = process.env.PORT || 3000; app.listen(PORT, () => { console.log(`Server is running on port ${PORT}`);