i'm trying to Set Signature Cookies from AWS AppSync Resolver.
/**
* Sends a request to the attached data source
* @param {import('@aws-appsync/utils').Context} ctx the context
* @returns {*} the request
*/
export function request(ctx) {
// Update with custom logic or select a code sample.
return {
operation: 'Invoke',
payload: ctx.source.movie
}
}
/**
* Returns the resolver result
* @param {import('@aws-appsync/utils').Context} ctx the context
* @returns {*} the result
*/
export function response(ctx) {
util.http.addResponseHeader("Set-Cookie", `CloudFront-Key-Pair-Id=${ctx.result.cookies['CloudFront-Key-Pair-Id']}; Path=/; Domain=localhost`)
util.http.addResponseHeader("Set-Cookie", `CloudFront-Signature=${ctx.result.cookies['CloudFront-Signature']}; Path=/; Domain=localhost`)
util.http.addResponseHeader("Set-Cookie", `CloudFront-Expires=${ctx.result.cookies['CloudFront-Expires']}; Path=/; Domain=localhost`)
util.http.addResponseHeader("Test", `Test=test; Path=/; Domain=localhost`)
return ctx.result.data
}
I use addResponseHeader method and it looks like Set-Cookie doesn't work, but "Test" header is working perfectly. I don't get any cookies in my response and also when I check application cookies in Dev Tools it's not showing cookies from response. Is Set-Cookie header blocked? Am I doing something wrong? Is there any other option how I can set user signature cookies?