Another approach would be to fix the Content-Type header.
Here is middleware code to do this:
exports.overrideContentType = function(){
return function(req, res, next) {
if (req.headers['x-amz-sns-message-type']) {
req.headers['content-type'] = 'application/json;charset=UTF-8';
}
next();
};
}
This assumes there is a file called util.js located in the root project directory with:
util = require('./util');
in your app.js and invoked by including:
app.use(util.overrideContentType());
BEFORE
app.use(express.bodyParser());
in the app.js file. This allows bodyParser() to parse the body properly...
Less intrusive and you can then access req.body normally.