Blocked cross-origin response in LandingPage (CORB)


#1

Dear Hubspot Developer Team,

I'm trying to make an API request from my custom HubL in my Hubspot Template.
This is how I implemented the request:

	function check_ContactExists(vobjInput) { 
		var vobjRequest = new XMLHttpRequest();
		
		vobjRequest.onreadystatechange = function() {
			if (this.readyState == 4 && this.status == 200) {
			var vobjResponse = JSON.parse(this.responseText);
					
				if (vobjResponse.status == "error"){
				  alert('Contact does not exists!');
				}
				else{
				  alert('Contact exists: ' + vobjResponse.vid);
				}
			}
		};
		
		vobjRequest.open("GET", "https://api.hubapi.com/contacts/v1/contact/email/testingapis@hubspot.com/profile?hapikey=demo", true);
		vobjRequest.send();
	}

But now I keep getting this error message:
Cross-Origin Read Blocking (CORB) blocked cross-origin response https://api.hubapi.com/contacts/v1/contact/email/testingapis@hubspot.com/profile?hapikey=demo with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.

What can I do to retrieve the response?

Kind regards


#3

Welcome, @sfis!

At this time, the Contacts API does not support cross-origin (CORS) requests because they would expose authentication to anyone browsing your site.

To check the existence of a contact, you must first make a request to an external server that could then add the needed authentication (whether API key or OAuth token) to this Contacts API endpoint server-side.