Why am I getting a CORS error when trying to implement my form?

Are you seeing an error that looks like this when implementing a form within our editor?


The error message you’re seeing is related to “CORS”, a security feature enforced by web browsers to prevent malicious attacks from other domains.

In most cases, requests should not be made directly to the beehiiv API from a browser since that would expose your API key, which is a sensitive piece of information that should not be shared publicly. 

Our API service has enabled CORS restrictions to prevent unauthorized access to our resources from unauthorized domains.

To solve this problem, we recommend using your own backend server as a proxy to access the API. By doing this, you can safeguard your API key and control the specific resources your website interacts with. 

Although you will need to set up your own CORS policies for the proxy server you connect to, using a server to access the beehiiv API will eliminate any CORS issues that may have occurred when accessing it from a web browser.

Was this article helpful?