Which response header should you add to allow only specific browser and mobile sessions to submit metrics to your HTTP Cloud Function?

Disable ads (and more) with a premium pass for a one time $4.99 payment

Prepare for the Google Cloud Professional Cloud Developer Test. Benefit from mock assessments featuring flashcards and multiple-choice format, each furnished with hints and detailed explanations. Excel in your exam with confidence!

To ensure that only specific browser and mobile sessions are allowed to submit metrics to your HTTP Cloud Function, the response header you would add is Access-Control-Allow-Origin. This header is a critical part of the Cross-Origin Resource Sharing (CORS) protocol, which governs how web browsers handle requests for resources hosted on a different origin (domain, protocol, or port) than the one that served the web page.

In this context, specifying Access-Control-Allow-Origin: https://www.example.com permits only requests originating from that exact domain. This restricts access to your Cloud Function to clients that are making requests from https://www.example.com, effectively adding a layer of security by preventing other origins from submitting metrics, which could be essential for controlling access to sensitive data or functionality.

By choosing the domain with the "www" prefix, you can enforce that only submissions from that specific site are allowed. This is particularly important for web applications that want to maintain control over which clients can interact with their services.

Other options such as using a wildcard (*) would allow any origin to submit metrics, which undermines the goal of restricting access. Similar reasoning applies for allowing subdomains or less specific domains; those configurations would either be too permissive or not meet the requirement of

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy