-1

I'm trying to run JavaScript as a snippet starting from one domain and do fetch request to a google search and I keep getting this error:

'Access to fetch at 'https://www.google.com/' from origin 'https://www.somewebsite.org' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I tried many ways to fix it by passing headers and it did work. Not sure at this point what else I can do.`

VLAZ
  • 26,331
  • 9
  • 49
  • 67
NoNam4
  • 457
  • 1
  • 4
  • 12

1 Answers1

0

It is the server (https://www.google.com/ in this case) of the requested resource that is responsible for and controls the CORS headers necessary. In order for you to be able to access the resource from your origin domain, the CORS policy that google serves will have to allow your website to request it.

Zain Syed
  • 443
  • 4
  • 12