QuestionQ73

VerifiedIntegrating applications with Google Cloud services

An application uses an HTTP Cloud Function to process user activity from both desktop-browser and mobile-application clients. The function will be the endpoint for all metric submissions made with HTTP POST.

Because of legacy restrictions, the function must be mapped to a domain separate from the domain that users request during web or mobile sessions. The Cloud Function domain is https://fn.example.com. Desktop and mobile clients use https://www.example.com. You need to add a header to the function’s HTTP response so that only those browser and mobile sessions can submit metrics to the Cloud Function. Which response header should you add?

Explanation

Access-Control-Allow-Origin authorizes a specific requesting origin for cross-origin browser requests. Setting it to https://www.example.com permits clients served from that origin to call the function at https://fn.example.com; it neither permits every origin nor incorrectly authorizes the function’s own origin. HTTP header field names are case-insensitive. Google Cloud documents configuring cross-origin access to an HTTP function by setting Access-Control-Allow-Origin on its response.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!