I have a simple Lambda function that takes in some text, and returns that text as a response. I hooked it up with AWS API Gateway and tested it out in their console and also on Postman. I enabled CORS, and the headers on Postman seem to be right, the Access-Control-Allow-Origin
is set to *.
Here's the Postman result:
I couldn't get it working on my local, so I decided to host a static page here:
https://smileyfacetest.firebaseapp.com/
test = {"text": ":)"}
$.post( "https://pq8thdrp0a.execute-api.us-west-2.amazonaws.com/dev", test)
.done(function( data ) {
console.log(data);
});
But still got an error of:
XMLHttpRequest cannot load https://pq8thdrp0a.execute-api.us-west-2.amazonaws.com/dev. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://smileyfacetest.firebaseapp.com' is therefore not allowed access. The response had HTTP status code 400.
Is there anything I'm doing wrong on the frontend? If it's working on Postman, and I have CORS enabled on the endpoint for the API, I don't see why it should be throwing an error. Any help would be really appreciated!
Here's the API endpoint if you want to try it in Postman: