Skip to content

Using Vandium with AWS SAM CLI  #35

Description

@skylerrichter

What are the best practices for using Vandium with AWS SAM CLI?

Everything works great when I am using CLI events and Postman to test my endpoints, however when I try to consume endpoints via my client application CORS does not seem to be enabled.

I have added this to my handler:

.cors({
  allowOrigin: 'http://localhost:8080',
  allowCredentials: true
})

And I have this in my SAM template:

Api:
  Cors:
    AllowMethods: "'*'"
    AllowHeaders: "'*'"
    AllowOrigin: "'*'"

However Vandium does not respond to the pre flight OPTION request, and does not seem to have a method for defining OPTION routes.

I had to make a vanilla lambda to respond to OPTION requests:

exports.handler = function (event, context, callback) {
  callback(null, {
    'statusCode': 200,
    'headers': {
      'Access-Control-Allow-Origin': 'http://localhost:8080',
      'Access-Control-Allow-Headers': 'Content-Type',
    },
  });
}

What is the right way of dealing with this?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions