APIs & Integrations

NUdayakumar
Participant

CORS issue

SOLVE

Hello All,

 

We have an React Application calling the Contacts API via AWS Lambda since we were getting CORS issue while trying to access the API directly from React APP. But even after implementing a AWS Lambda function we are still getting the same CORS error. This is really urgent can anyone please help. The error 

 

Access to XMLHttpRequest at 'https://devapi.ourdomain.com/crm/' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

0 Upvotes
1 Accepted solution
stefen
Solution
Key Advisor | Partner
Key Advisor | Partner

CORS issue

SOLVE

@NUdayakumar @dennisedson if you're getting CORS errors its because you are trying to access an API designed for servers from the browser. Can you make the request via node.js on the server instead of via the browser?

If you have to make the request client side then you'll want to setup a proxy server similar to what I did here: https://www.kelp.agency/blog/how-to-enable-cors-ajax-requests-for-any-hubspot-api

Stefen Phelps, Community Champion, Kelp Web Developer

View solution in original post

4 Replies 4
stefen
Solution
Key Advisor | Partner
Key Advisor | Partner

CORS issue

SOLVE

@NUdayakumar @dennisedson if you're getting CORS errors its because you are trying to access an API designed for servers from the browser. Can you make the request via node.js on the server instead of via the browser?

If you have to make the request client side then you'll want to setup a proxy server similar to what I did here: https://www.kelp.agency/blog/how-to-enable-cors-ajax-requests-for-any-hubspot-api

Stefen Phelps, Community Champion, Kelp Web Developer
NUdayakumar
Participant

CORS issue

SOLVE
Hey Guys,

Thanks for the responses. We were able to solve this by creating an API endpoint and lambda function in AWS. The contact creation is now working and really appreciate the help.

Thanks,
Nirmal Kumar
Jaycee_Lewis
Community Manager
Community Manager

CORS issue

SOLVE

Thanks for the update, @NUdayakumar

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
dennisedson
Community Manager
Community Manager

CORS issue

SOLVE

@stefen , what are you thinking 😀

Thanks,

Dennis




HubSpot Community Developer ShowMake sure to subscribe to our YouTube channel
where you can find the HubSpot Community Developer Show
0 Upvotes