I am trying to access a publicily shared google drive video file from my react website , since google drive file is not a absolute downloadable file,I am trying to play google drive video with a Custom Player ,so before showing the video in the player , I need to extract absolute file url with an XHR request.But I cannot access googledrive with XHR beacause it will only get CORS errors.Is there a way to request other server domains from a client domain without any serverside changes?
I am trying to access a publicily shared google drive video file from my react website , since google drive file is not a absolute downloadable file,I am trying to play google drive video with a Custom Player ,so before showing the video in the player , I need to extract absolute file url with an XHR request.But I cannot access googledrive. with XHR beacause it will only get CORS errors.Is there a way to request other server domains from a client domain without any serverside changes?
Share Improve this question asked Jul 24, 2021 at 5:49 Lwin Moe HeinLwin Moe Hein 5091 gold badge5 silver badges13 bronze badges 3- 3 The only way to spoof a request origin is through server-side code. – Wais Kamal Commented Jul 24, 2021 at 5:51
- 1 @WaisKamal - you don't have to spoof anything from a server since servers are not subject to CORS rules – Bravo Commented Jul 24, 2021 at 5:55
- 1 @Bravo sometimes the same-origin policy is enforced by the server providing the content. In this case you have to spoof the origin. – Wais Kamal Commented Jul 24, 2021 at 5:57
1 Answer
Reset to default 8Short Answer
No. It's impossible to get around CORS without modifying server-side code.
Long Answer
CORS (Cross Origin Resource Sharing) is a browser's way of letting developers connect to external APIs from your website.
But that is an obvious security risk, not all APIs are meant to be public. To fix this risk, CORS only allows you to municate to servers that have CORS enabled.
Unless the owners of the server suddenly decide to enable CORS, you cannot make a request from your website to the server.
The only way
The only way to achieve your goal is to send the request from a server. When making requests from server to server, there is no CORS (it only exists on browsers).