Wednesday, 10 May 2017

Sending Response Header with the Serverless Framwork on AWS

I'm using the Serverless Framework for my Lambda functions on AWS. How can I send authorization headers? My current config:

Lambda function:

module.exports.createUser = (event, context, callback) => {

     let response = {
            statusCode: 302,
            headers: {
                "Authorization": userUtil.getToken(userId)
            },
            body: ""
        };
    callback(null, response);
    return;
}

serverless.yml:

createUser:
    handler: functions/user.createUser
    events:
      - http:
          path: users
          method: post
          cors: true
          integration: lambda

The above config sends the response object as body. The status is still 200.

I'm using Serverless v1.10



via rish08

No comments:

Post a Comment