-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
I'm trying to send a custom header to my Serverless endpoint using AngularJS and JQuery, and whenever I do I get a 403 error during the OPTIONS preflight check.
My s-function.json
has:
"requestTemplates": "$${apiRequestTemplate}",
..
"custom": {
"cors": {
"allowOrigin": "*",
"allowHeaders": ["Content-Type", "X-Amz-Date", "X-Custom-Auth", "X-Api-Key"]
}
}
My s-templates.json
file has:
"apiRequestTemplate": {
"application/json": {
"auth": "$input.params('X-Custom-Auth')"
}
}
I've tested it with a simple JQuery request:
$.ajax({
url: "https://***.execute-api.us-east-1.amazonaws.com/dev/test",
type: 'GET',
dataType: 'json',
beforeSend: function(xhr) {
xhr.setRequestHeader('X-Custom-Auth', 'MY_AUTH');
}
})
.done(function(data) {
console.log('JQUERY',data)
})
.fail(function(data) {
console.log('JQUERYFAIL',data)
});
})
If I comment out the beforeSend
block, the request completes successfully.
Metadata
Metadata
Assignees
Labels
No labels