From e5974a012109411f05d8a01e89bd92b3522f81ac Mon Sep 17 00:00:00 2001 From: EGrun Date: Wed, 13 Sep 2017 17:29:34 -0400 Subject: [PATCH] add cors headers --- handler.ts | 4 ++++ serverless.yml | 2 ++ 2 files changed, 6 insertions(+) diff --git a/handler.ts b/handler.ts index 2530b7d..3042f9e 100644 --- a/handler.ts +++ b/handler.ts @@ -17,6 +17,10 @@ class WebUtils { public static generateResponse(statusCode: number, message: string) { return { 'statusCode': statusCode, + headers: { + "Access-Control-Allow-Origin" : "*", // Required for CORS support to work + "Access-Control-Allow-Credentials" : true // Required for cookies, authorization headers with HTTPS + }, body: JSON.stringify({ 'result': message }) diff --git a/serverless.yml b/serverless.yml index f63adb0..a3e44e9 100644 --- a/serverless.yml +++ b/serverless.yml @@ -55,6 +55,7 @@ functions: - http: path: ${self:service}/${self:custom.entity} method: post + cors: true put: handler: handler.put @@ -63,6 +64,7 @@ functions: - http: path: ${self:service}/${self:custom.entity}/{${self:custom.identityKey}} method: put + cors: true plugins: - serverless-plugin-typescript