3

I have a script which I give to my clients and they put it in their web pages.
I want to check inside that script if the domain is safe using Google's Safe Browsing API. When the script loads, I make an API request for the current domain with the client key I got from Google.
"Client key" according to Google:

API requests are sent directly to Google from your clients' browsers

$.ajax({
    url: "https://sb-ssl.google.com/safebrowsing/api/lookup?client=demo-app&key=AIzaSyBx5EyJlhg-oB4inoO15fMlP37ljeDP98o&appver=1.5.2&pver=3.1&url=http%3A%2F%2Fstackoverflow.com",
    method: "GET",
    success: function (result) {
        self.onDataReceived(result);
    }
});

But the browser blocks my request due to No 'Access-Control-Allow-Origin' header is present on the requested resource.

Sharon Haim Pour
  • 6,595
  • 12
  • 42
  • 64

1 Answers1

2

It appears that the Safe Browsing API does not support cross origin requests and your best option is running a proxy on your domain.

abraham
  • 46,583
  • 10
  • 100
  • 152