CORS angular 6 creating Contact using API

forms
contacts

#1

Hello

I am try to post to API to create contact to crm, but I am getting error for Sites orign

See Error below

Failed to load https://api.hubapi.com/contacts/v1/contact/?hapikey=HAPIKEY: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.


Error getting refresh token
#2

Hi @codephree, Please refrain from posting your hapikey here in the future, as these forums are public, and anybody can use them to make requests to your portal and contacts. To be safe, I'd deactivate the key in your Integrations Settings, and activate a new one.

That said, our APIs do not support cross-origin AJAX requests, since that could expose your API key to anyone viewing that page. You’ll need to make the AJAX request to your server, which would then add the api key to the request URL and make the request to the HubSpot API server-side.

There are a few exceptions to this rule, however, which you can find here: https://developers.hubspot.com/docs/faq/do-hubspot-apis-support-ajax-request