i use https://github.com/nuxt-community/express-template
but i don't know why Build only in dev mode?
// Build only in dev mode
if (config.dev) {
const builder = new Builder(nuxt)
builder.build()
}
in here define a post router like this https://github.com/nuxt-community/express-template/blob/master/template/server/api/users.js
import { Router } from 'express'
const router = Router()
router.post('/doc_enter', function(req, res, next) {
if (req.body.pw) {
return res.json({success:req.body.pw})
}
})
but req.body is undefined
i use bodyParser at https://github.com/nuxt-community/express-template/blob/master/template/server/index.js
const bodyParser = require('body-parser')
app.use(bodyParser.json({limit:'900kb'}))
app.use('/api', api)
const nuxt = new Nuxt(config)
// Build only in dev mode
if (config.dev) {
const builder = new Builder(nuxt)
builder.build().catch((error) => {
console.error(error)
process.exit(1)
})
}
app.use(nuxt.render)
now the req.body has value .but other proxy PHP API timeout which has post data
superagent
.post('/api/user/login')
.send({ ip, ...form }) // sends a JSON post body
.set('accept', 'json')
.end((err, res) => {
// Calling the end function will send the request
})
The request headers Provisional headers are shown
What should i do if i wanna keep the proxy PHP API and express middleware api all be right?
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c2318">#c2318</a>)</em></sub></div>