Search code examples
amazon-web-servicescookiesaws-lambdasetcookie

Set Cookies not setting up in the browser


I'm using AWS Lambda function setup with the API Gateway. I have been trying to set-cookies to the application but even though it shows in the console headers, it is not setting up in the browser.

  callback(null, {
        statusCode: 302,
        headers: {
            'Access-Control-Allow-Origin': '*',
            'Access-Control-Allow-Methods': 'GET,PUT,POST,DELETE,PATCH,OPTIONS',
            'Location': "https://example.com",
            'Set-Cookie': cookieString,
            'Content-Type': 'application/json'


        },
        body: null
    } );

https://aws.amazon.com/blogs/compute/simply-serverless-using-aws-lambda-to-expose-custom-cookies-with-api-gateway/ Tried implementing this but in the browser cookies were not set. enter image description here

enter image description here


Solution

  • After changing the s3 bucket hosted static website to an API gateway, cookies passed

    http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Cookies.html