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}`);