appbaseio / reactivesearch

Search UI components for React and Vue
https://opensource.appbase.io/reactivesearch
Apache License 2.0
4.89k stars 466 forks source link

CORS preflight Major Issue #533

Closed coommark closed 5 years ago

coommark commented 5 years ago

Issue Type: I have a proxy exactly like the sample here, hosted on https://search.commercesite.com. The client is hosted on https://www.commercesite.com. On elasticsearch.yml, I have the usual

http.cors.enabled: true
http.cors.allow-credentials: true
http.cors.allow-origin: /https?:\/\/(localhost)?(127.0.0.1)?(:[0-9]+)?/
http.cors.allow-headers: X-Requested-With, X-Auth-Token, Content-Type, Content-Length, Authorization, Access-Control-Allow-Headers, Accept

Below is the reactivesearch setting used to connect to the proxy:

export const settings = {
    url: 'https://search.commercesite.com/',
    app: 'commercesite',
    type: 'products'
};

Everything worked fine during testing, until I added SSL to both services on launch date, then the CORS issues started, the error being like this:

Failed to load https://search.commercesite.com/commercesite/products/_msearch?: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://www.commercesite.com' is therefore not allowed access

Platform: Web, SSR

I added this express cors package to https://www.commercesite.com, however the error persisted. My thinking is reactivesearch calls the proxy directly, as a result the cors package will not be of value here.

Long story short, we suspended our big launch day because of cors! How ironic right?

Ok now PLEASE HELP!

siddharthlatest commented 5 years ago

@coommark Did you add something like Nginx for configuring SSL? The same things that you did to Elasticsearch in terms of allowing CORS will have to be applied there too.

siddharthlatest commented 5 years ago

Closing this issue due to inactivity. Feel free to comment if this persists.

akshay-1707 commented 2 years ago

hey @siddharthlatest i m facing cors error

<ReactiveBase app="appname" credentials="abcdef123:abcdef12-ab12-ab12-ab12-abcdef123456"

<Component1 .. /> <Component2 .. />

this is the code i m using i have plae my aws cluster url in place of app and in app i have place cluster name

Adding image for reference Screenshot 2022-02-15 at 1 45 02 PM (2) e