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,260 points
1,880 views

1 answer to this question.

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
0 votes
1 answer
+9 votes
17 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,280 points

edited Jul 10, 2023 by Khan Sarfaraz 128,435 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 2, 2018 in AWS by Cloud gunner
• 4,670 points
1,781 views
0 votes
1 answer
0 votes
1 answer

how to access AWS S3 from Lambda in VPC

With boto3, the S3 urls are virtual by default, ...READ MORE

answered Sep 28, 2018 in AWS by Priyaj
• 58,020 points
10,111 views
+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 10, 2018 in AWS by Priyaj
• 58,020 points
981 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP