I have one frontend application at AWS beanstalk (i.e.: http://app1.elasticbeanstalk.com/) and second backend application at AWS beanstalk (i.e.: http://app2.elasticbeanstalk.com/). When I am making ajax post by jquery from frontend application to backend application I am getting:
XMLHttpRequest cannot load http://app2.elasticbeanstalk.com/restUrl.
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://app1.elasticbeanstalk.com' is therefore not allowed access.
I am using tomcat platform on both sides of ajax request. I would love to use "cors.allowed.origins" parameter from documentation: https://tomcat.apache.org/tomcat-8.0-doc/config/filter.html#CORS_Filter/Initialisation_parameters . But I do not know how edit this parameter in AWS administration panel. How to configure beanstalk for app2 to accept parametrized domain from app1? I do not want to hardcode domain inside WAR.
Diagram with communication:
b
+ l+------+Internet +
| o| + |
| c| |JQuery Ajax request |
+----k+-------------------------------------------+
| e| | |
| d| v |
| | http://app1.elasticbeanstalk.com/ |
| c| + (frontend app security group) |
+----o+-------------------------------------------+
| n| | |
| n| |JQuery Ajax request |
| e| v |
| c+-----> http://app2.elasticbeanstalk.com/ |
| t + (backend app security group) |
| i | |
+----o--------------------------------------------+
| n | |
| | JDBC Query |
| v |
| RDS (RDS security group) |
+-------------------------------------------------+