# Running into CORS errors when using elasticsearch-js client

**URL:** <https://discuss.elastic.co/t/running-into-cors-errors-when-using-elasticsearch-js-client/16695>\
**Category:** Elasticsearch\
**Created:** [March 29, 2014, 2:30pm UTC](https://discuss.elastic.co/t/running-into-cors-errors-when-using-elasticsearch-js-client/16695 "2014-03-29T14:30:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pulkitsinghal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pulkitsinghal/32/802_2.png) [@pulkitsinghal](https://discuss.elastic.co/u/pulkitsinghal)\
**Post date:** [March 29, 2014, 2:30pm UTC](https://discuss.elastic.co/t/running-into-cors-errors-when-using-elasticsearch-js-client/16695/1 "2014-03-29T14:30:36Z")

</div>

I'm running into the following error message when using elasticsearch-js[https://github.com/elasticsearch/elasticsearch-js/](https://github.com/elasticsearch/elasticsearch-js/)client:

> No 'Access-Control-Allow-Origin' header is present on the requested  
> resource. Origin '[http://localhost:9090](http://localhost:9090)' is therefore not allowed access.

There is a brief mention of cross browser in the code:

> <https://github.com/elastic/elasticsearch-js/blob/30f27494644b0dd893f69d69327a5f41c723da52/src/lib/connectors/xhr.js?L-20#L20-L24>

But looking at that I'm not sure how to initialize the client any  
differently.

My topology looks like:  
express+nodejs (laptop) \<-\> APIGEE (proxy) \<-\> Elasticsearch

Perhaps this is not about the elasticsearch-js client?

Thanks!

- Pulkit

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/aa65d51d-8f5a-4a52-aa2f-ea69d6e0590b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/aa65d51d-8f5a-4a52-aa2f-ea69d6e0590b%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![pulkitsinghal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pulkitsinghal/32/802_2.png) [@pulkitsinghal](https://discuss.elastic.co/u/pulkitsinghal)\
**Post date:** [March 29, 2014, 3:23pm UTC](https://discuss.elastic.co/t/running-into-cors-errors-when-using-elasticsearch-js-client/16695/2 "2014-03-29T15:23:44Z")

</div>

Yup this didn't have anything to do with the client. For anyone else who is  
a big fan of pairing elastisearch with APIGEE ... the solution is  
here: [api - Apigee Pre-Flight Options Requests - Stack Overflow](http://stackoverflow.com/questions/21193647/apigee-pre-flight-options-requests)

On Saturday, March 29, 2014 9:30:36 AM UTC-5, pulkitsinghal wrote:

> I'm running into the following error message when using elasticsearch-js[https://github.com/elasticsearch/elasticsearch-js/](https://github.com/elasticsearch/elasticsearch-js/)client:
> 
> > No 'Access-Control-Allow-Origin' header is present on the requested  
> > resource. Origin '[http://localhost:9090](http://localhost:9090)' is therefore not allowed access.
> 
> There is a brief mention of cross browser in the code:
> 
> [https://github.com/elasticsearch/elasticsearch-js/blob/30f27494644b0dd893f69d69327a5f41c723da52/src/lib/connectors/xhr.js?L-20#L20-L24](https://github.com/elasticsearch/elasticsearch-js/blob/30f27494644b0dd893f69d69327a5f41c723da52/src/lib/connectors/xhr.js?L-20#L20-L24)  
> But looking at that I'm not sure how to initialize the client any  
> differently.
> 
> My topology looks like:  
> express+nodejs (laptop) \<-\> APIGEE (proxy) \<-\> Elasticsearch
> 
> Perhaps this is not about the elasticsearch-js client?
> 
> Thanks!
> 
> - Pulkit

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/139a61a0-2786-4d66-9a0c-55592dae28d6%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/139a61a0-2786-4d66-9a0c-55592dae28d6%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:39am UTC](https://discuss.elastic.co/t/running-into-cors-errors-when-using-elasticsearch-js-client/16695/3 "2017-07-06T01:39:44Z")

</div>


