This commit is contained in:
notnull 2019-04-08 16:37:17 -04:00
parent cab4dbfda3
commit 77eeea605f
2 changed files with 4 additions and 4 deletions

View File

@ -7,6 +7,9 @@ const port = process.env.PORT || 3001
app.use(morgan('tiny')) app.use(morgan('tiny'))
app.use(proxy('/api/', { target: 'http://localhost:1337/',
changeOrigin: true }))
// body parsing middleware // body parsing middleware
app.use(express.json()) app.use(express.json())
app.use(express.urlencoded({ extended: true })) app.use(express.urlencoded({ extended: true }))
@ -14,9 +17,6 @@ app.use(require('body-parser').text())
app.use(express.static(path.join(__dirname, 'dist'))) app.use(express.static(path.join(__dirname, 'dist')))
//http://localhost:1337
app.use(proxy('/api', { target: 'http://localhost:1337' }))
app.get('*', (req, res) => { app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, 'dist', 'index.html')) res.sendFile(path.resolve(__dirname, 'dist', 'index.html'))
}) })

View File

@ -23,7 +23,7 @@ router.get('/:id', async (req, res, next) => {
router.post('/', async (req, res, next) => { router.post('/', async (req, res, next) => {
try { try {
const comment = await Comment.create(req.body) const comment = await Comment.create(req.body)
res.status(201).json(comment) res.json(comment)
} catch (err) { } catch (err) {
next(err) next(err)
} }