Has anyone gotten the AWS API Gateway to work with an Angular.js front-end? I have a lambda function that's exposed via a POST method in the API Gateway. I set up the headers as indicated by this doc: http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors.html
I tested it in Postman and it works great. I didn't have to do anything special, but when I do the $http.post()
call I only get No 'Access-Control-Allow-Origin'
header is present on the requested resource. Origin http://localhost:9000
is therefore not allowed access. The response had HTTP status code 500.
as the response.
Amazon API Gateway is an AWS service for creating, publishing, maintaining, monitoring, and securing REST, HTTP, and WebSocket APIs at any scale. API developers can create APIs that access AWS or other web services, as well as data stored in the AWS Cloud .
As mentioned before, AWS API Gateway can be configured by using API specifications written in Swagger. Additionally, a set of extensions have been defined for the API Gateway to capture most of its specific properties, like integrating Lambda functions or using Authorizers.
Note: This post focuses on Amazon API Gateway REST APIs used with OAuth 2.0 and custom AWS Lambda authorizers. API Gateway also offers HTTP APIs, which provide native OAuth 2.0 features.
Api Gateway team here.
Hopefully by now you've checked out the new 'Enable CORS' feature in the console. Even if your dev workflow is outside the console, you could quickly setup a test API and look at the header configurations that the console sets up for you, then copy those to your Swagger def or whatever solution you've come up with.
The docs guide should still apply in either case. You'll need the 3 headers: Access-Control-Allow-Methods, Access-Control-Allow-Origin, and Access-Control-Allow-Headers. The values of these will depend on your API.
If you'd like to send me the API resource you're trying to invoke, I can take a look from our side.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With