I'm having a problem with my serverless setup. I am new to httpAPI, just migratinging from http. I'd like to get it working but can not sort out CORS. Postman returns the response just as I expect but chrome is throwing a CORS error. Any help on what I've got wrong would be great.
my serverless.yml looks like
service: serverless
frameworkVersion: '3'
provider:
name: aws
runtime: nodejs16.x
httpApi:
cors: true
authorizers:
customAuthorizer:
type: request
functionName: authorizerFunc
functions:
user:
handler: src/users/index.handler
events:
- httpApi:
path: /user
method: any
authorizer:
name: customAuthorizer
authorizerFunc:
handler: src/authorizer/index.handler
the handler for src/users/index.handler is:
module.exports.handler = async (event, context, callback) => {
callback(null,{
statsCode: 200,
body:{message:'Success'}
});
}
This works fine in thunder client/postman but i get cors issues in the web browser. What am I missing here?