aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.42k stars 2.12k forks source link

Set cookies in lambda resolver #9688

Open Punith13 opened 2 years ago

Punith13 commented 2 years ago

Is this related to a new or existing framework?

No response

Is this related to a new or existing API?

GraphQL API

Is this related to another service?

Lambda

Describe the feature you'd like to request

I want to be able to set cookies in my lambda resolver. This would help me store secure, HTTP-only cookies.

Describe the solution you'd like

I want to set cookies in the lambda function like ` exports.handler = async (event, context, callback) => {

const response = { headers : { "Set-Cookie" : [example-cookie=value] } } callback(null, response)

and the set cookie must be available as the response header of the Graphql HTTP call from the client.

Describe alternatives you've considered

Tried to set the cookie client-side, but it is an insecure solution.

Additional context

No response

Is this something that you'd be interested in working on?

yanlin96 commented 2 years ago

Hi got a similar issue,

Here is my testing experience.

I set up a nginx server locally with the same domain as AppSync endpoint like ".amazonaws.com" to host a front end react app locally. I am using the "$util.http.addResponseHeader("Set-cookie", xxxx-yyyy)" in the VTL resolver, however, I CANNOT see it in the response header while call the api, therefore, not cookie stored in the browser.