enabling cors on a nginx server in ElasticBeanstalk?


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.awselasticbeanstalk.com/api/get_stuff etc.

Im trying to enable CORS so i can access the server from my javascript application (the client).

As per amazon documentation I can edit or extend the nginx configuration adding a config file to the .ebextensions folder.


but this is still not working for me.


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:

Leave a Reply