Im deploying my Nodejs app to AWS Elastic Beanstalk running nginx.
The app is essentially an api, which i can make calls to and retrieve back JSON data i.e. myapi.aw
If you set CORS headers in the response that goes out of your node/express application, you don't need to add anything to Nginx configuration.
Below is the configuration that worked for me, also running node.js on Beanstalk, and a cloudfront-hosted client application calling the API.
Modify as needed:
server.use(function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*')
res.header('Access-Control-Allow-Credentials', true)
res.header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS')
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept')
next()
})