AWS Cloudfront is not classifying the Tablet device as Tablet?

0 votes

When using lambda I could either get 'Desktop' or 'Mobile'.

but if I send a Tablet UserAgent, it is not classifying it as Tablet.

Here is the lambda code that i used!

exports.handler = (event, context, callback) => {
    var region = process.env.AWS_REGION ? process.env.AWS_REGION : 'us-east-1';
    console.log(region);
    console.log(event);

    var device = {};
    if( event.headers['CloudFront-Is-Mobile-Viewer']  === "true" )
         device.device = 'Mobile';
    else if ( event.headers['CloudFront-Is-Tablet-Viewer']  === "true" )
         device.device = 'Tablet';
     else
         device.device = 'Desktop';

     var response = {
        statusCode: 200,
        body: JSON.stringify(device)
    };

    callback(null, response);
};

I did double checked the headers received to lambda as well.

'CloudFront-Is-Desktop-Viewer': 'true',
'CloudFront-Is-Mobile-Viewer': 'false',
'CloudFront-Is-SmartTV-Viewer': 'false',
'CloudFront-Is-Tablet-Viewer': 'false',
'CloudFront-Viewer-Country': 'US',

Nov 2, 2018 in AWS by findingbugs
• 3,140 points
48 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

You can seek reference from the below link:

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/header-caching.html#header-caching-web-device

So if you are down-converting these to a single device categorization, you are likely to get the most sensible result if you test them in this order, stopping on the first match:

CloudFront-Is-SmartTV-Viewer
CloudFront-Is-Tablet-Viewer
CloudFront-Is-Mobile-Viewer
CloudFront-Is-Desktop-Viewer
answered Nov 2, 2018 by Subhodeep Ghosh

Related Questions In AWS

+1 vote
1 answer
+3 votes
12 answers

AWS VPC - What is the difference between Internet Gateway & NAT

Internet Gateway An Internet Gateway is a logical connection ...READ MORE

answered Apr 24, 2018 in AWS by Flying geek
• 3,130 points
5,357 views
0 votes
1 answer

if instance is a part of some AutoScaling Group in AWS or not ?

You can run this command below on ...READ MORE

answered Jun 1, 2018 in AWS by Cloud gunner
• 4,240 points
21 views
0 votes
1 answer

What is the difference between Amazon Cloudfront and S3

major difference is that cloudfront allows you ...READ MORE

answered Jul 9, 2018 in AWS by Priyaj
• 56,100 points
68 views
0 votes
1 answer
0 votes
1 answer
+1 vote
10 answers
0 votes
1 answer

AWS email saying have exceeded the free-tier limit.

I got a similar message, except I ...READ MORE

answered Jul 9, 2018 in AWS by Priyaj
• 56,100 points
18 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.