How to detect whether or not a user or resource is being geo-blocked?
Given
- Two AWS CloudFront Distributions:
- Website at
www.example.com - 2nd domain at
videos.example.comwhich is geo-restricted/blocked via CloudFront geo restriction
- Website at
- CORS is working, it is possible to execute requests from the website towards the video CDN if user is not geo blocked
- When a user accesses the video CDN he'll see
http/403 Forbiddenorhttp/200 OKdepending on this geo location.
Problem
A geo blocked user cannot probe resources from the restricted CDN and check the return code being either http/200 OK or http/403 Forbidden:
Since the requests originates from www. and then send towards a different domain video. it is a different domain so the browser must send a CORS/preflight requests. But this request will be blocked due to the geo restriction.
From JavaScript perspective it simply fails the CORS preflight with no error details.
I tried fetching different ContentTypes in combination with fetch mode: cors/no-cors that would qualify for a Simple Request and thus not require CORS — but no success so far.