I'm trying to authorize API Gateway requests for a Lambda Proxy Integration resource using a Cognito User pool.
From the client, all requests work fine without an Authorizer. When I add an Authorizer, GET requests work when authorized, but a POST/PUT/DELETE request gives me this error:
401 Access to XMLHttpRequest at [Endpoint] from origin [client] has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource
I have selected 'Enable CORS'
for the resource but it still won't work.
js request:
const jwt = this.$store.state.user
.getSignInUserSession()
.getIdToken()
.getJwtToken();
const config = {
headers: {
authorization: jwt,
},
id: generatedID,
name: 'generatedName',
};
axios.post(endpoint, config)
.then((val) => { this.info = val; })
.catch(err => console.log(err));
auth config: authorizer config
If I change request type from POST
to GET
, it works. If I remove the Authorizer from API Gateway, it works. What am I missing for POST/PUT/etc?
I want to get a 200/201 response and for the request to pass API Gateway authorization.