Closed davidquintard closed 6 years ago
Here is my cors config:
routing_controllers.useExpressServer(expressApp, {
cors : {
origin: [
"http://localhost:8100",
"http://staging.ionic."+process.env.HOSTNAME
],
methods:"GET,HEAD,PUT,PATCH,POST,DELETE",
allowedHeaders:"Origin,X-Requested-With,Content-Type,Accept, Accept-Encoding,Accept-Language,Authorization,Content-Length,Host,Referer,User-Agent",
exposedHeaders:"Origin,X-Requested-With,Content-Type,Accept, Accept-Encoding,Accept-Language,Authorization,Content-Length,Host,Referer,User-Agent",
credentials:true,
optionsSuccessStatus: 200 // some legacy browsers (IE11, various SmartTVs) choke on 204
},
defaultErrorHandler: false, // disable default error handler, only if you have your own error handler
// now import all our controllers. alternatively you can specify controllerDirs in routing-controller options
controllers: [__dirname + "/dist/modules/**/controllers/*.js"],
//middlewares: [__dirname + "/dist/middlewares/*.js"],
//interceptors: [__dirname + "/dist/interceptors/*.js"]
});
I found error.
I replaced
@Controller("/payment/braintree")
by
@JsonController("/payment/braintree")
If, like me, you just have this problem on a specific method, and don't want to convert the whole controller to JSON, you can do:
// should be installed as part of routing-controllers:
import { json } from 'body-parser'
import { Body, UseBefore, Post } from 'routing-controllers'
// ...
@Get('/foo')
@UseBefore(json())
doGet(@Body() body) {
body.bar
}
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Hi there, I can't retrieve data into my @Body() after a post request.
Ionic Call
Data is: let data = { 'nonceInput' : payload.nonce, 'forfait' : forfait }
Express server side:
body is {} request.body is {}