fix post
This commit is contained in:
parent
cab4dbfda3
commit
77eeea605f
@ -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'))
|
||||
})
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user