amplify-hosting icon indicating copy to clipboard operation
amplify-hosting copied to clipboard

Amplify Access logs always show no Cookies

Open shivennn opened this issue 7 months ago • 1 comments

Before opening, please confirm:

Amplify Hosting feature

Access logs, Custom headers

Is your feature request related to a problem? Please describe:

I am using Amplify hosting with custom domain and flow of request is as under.

Custom Cloud Front Distribution ----> Amplify App Origin

In Lambda Edge Function logs I observed cookies values passed from my custom Cloud Front Distribution but in Amplify Access logs of domain shows no cookies.

export const handler = (event, context, callback) => {
console.log("function invoked");
const request = event.Records[0].cf.request;
const uri = request.uri;
console.log(uri);
// Log the Cookie header
const headers = request.headers;
if (headers.cookie) {
    const cookies = headers.cookie.map(header => header.value).join('; ');
    console.log("Cookies: ", cookies);
} else {
    console.log("No Cookie header found");
}

console.log(request.uri);
return callback(null, request);
};

As discussed with AWS support team members Amplify managed Cloud Front Distribution has below settings which preventing cookie logging in Access Logs.

Headers : Accept , CloudFront-Viewer-Country , Host
Cookie logging : Off

workaround :

  • Use "S3+Cloud Front" Hosting but my application is Next JS SSR application and manual hosting not supported for Next JS SSR application in Amplify.

Describe how you'd like this feature to work

Provide Support for cookie logging in Amplify managed Cloud Front Distribution.

shivennn avatar Jul 11 '24 11:07 shivennn