I’m just building my first app with serverless on aws and I’m stuck on cors… I’m sure I’m doing something wrong.
This is my serverless.yml:
service: cgipub
frameworkVersion: ‘3’
provider:
name: aws
runtime: python3.9
stage: dev
region: us-west-2
iamRoleStatements:
- Effect: “Allow”
Action:
- “dynamodb:Query”
- “dynamodb:Scan”
- “dynamodb:GetItem”
- “dynamodb:PutItem”
- “dynamodb:UpdateItem”
Resource: “arn:aws:dynamodb:${self:provider.region}:*:table/UsersTable”
functions:
env:
handler: test.env
events:
- httpApi:
path: /env
method: get
cors: true
plugins:
- serverless-python-requirements
here is my javascript call where base_url is the url of the aws endpoint (ie xxxxxx.execute-api.us-west-2.amazonaws.com):
function make_api_call(func, data, callback) {
var url = ‘https://’ + cgipubconf[‘base_url’] + ‘/’ + func;
$.ajax({
type: “GET”,
url: url,
data: data,
success: function (response) {
callback(response);
},
error: function (response) {
console.log("Error: " + response);
},
});
}
I’m sure it’s something dumb, but what am I missing here? I plan to use this particular endpoint across SEVERAL different domain names each needs to call it. I tried just cnaming the deployed endpoint but then the ssl doesn’t match.