From 77eeea605f68b06d9e9fbadb572363ac5de47271 Mon Sep 17 00:00:00 2001 From: notnull Date: Mon, 8 Apr 2019 16:37:17 -0400 Subject: [PATCH] fix post --- server.js | 6 +++--- server/api/comments.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server.js b/server.js index 0231010..2e52d3e 100644 --- a/server.js +++ b/server.js @@ -7,6 +7,9 @@ const port = process.env.PORT || 3001 app.use(morgan('tiny')) +app.use(proxy('/api/', { target: 'http://localhost:1337/', +changeOrigin: true })) + // body parsing middleware app.use(express.json()) app.use(express.urlencoded({ extended: true })) @@ -14,9 +17,6 @@ app.use(require('body-parser').text()) app.use(express.static(path.join(__dirname, 'dist'))) -//http://localhost:1337 -app.use(proxy('/api', { target: 'http://localhost:1337' })) - app.get('*', (req, res) => { res.sendFile(path.resolve(__dirname, 'dist', 'index.html')) }) diff --git a/server/api/comments.js b/server/api/comments.js index 3e9f009..fe66029 100755 --- a/server/api/comments.js +++ b/server/api/comments.js @@ -23,7 +23,7 @@ router.get('/:id', async (req, res, next) => { router.post('/', async (req, res, next) => { try { const comment = await Comment.create(req.body) - res.status(201).json(comment) + res.json(comment) } catch (err) { next(err) }