CORS error when calling API | Community
Skip to main content
Harish_Gupta6
Level 6
February 18, 2019
Solved

CORS error when calling API

  • February 18, 2019
  • 1 reply
  • 4339 views

Hi,

I am trying to call Marketo rest API using the javascript on the CMS web page but I am getting CORS error. Is there any way to fix this?

Thanks

Harish G

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

There's no reason to use the browser to test, since the browser won't be the deployment platform. Use cURL, Postman, etc.

The reason for the CORS error should be self-evident: it isn't a browser API, so the Access-Control headers are not present.

1 reply

SanfordWhiteman
Level 10
February 18, 2019

You must never, ever, ever even consider calling the REST API directly from the browser. Just think about what you're exposing for a second.

Harish_Gupta6
Level 6
February 19, 2019

Hi Sanford,

Yes, agreed with you. Calling the rest API from the browser is not a safe way. But I am doing it for testing purpose.

From Server, I am able to call the API successfully but I was testing using browser-side also.

Thanks

Harish Gupta
SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
February 19, 2019

There's no reason to use the browser to test, since the browser won't be the deployment platform. Use cURL, Postman, etc.

The reason for the CORS error should be self-evident: it isn't a browser API, so the Access-Control headers are not present.