How to fix cross-origin error when request to Kylo API

420 Views Asked by At

I have a running instance of a Kylo Sandbox in a server called: kyloserver. I am trying to access Kylo API from my website, running in localhost:8080.

I try to use Search API calling url:

http://kyloserver:8400/proxy/v1/feedmgr/search?q=mary&rows=20&start=0

and using Basic Authentication in header like this (javascript):

Authorization: 'Basic ' + btoa(this.username + ":" + this.password)

The response is:

Failed to load http://kyloserver:8400/proxy/v1/feedmgr/search?q=mary&rows=20&start=0: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 403.

If I use swagger by logging into the UI I can get the results properly.

How can I access the API successfully?

(Kylo Version: 0.8.3)

Thanks.

2

There are 2 best solutions below

2
On BEST ANSWER

Kylo has disabled CORS support by default. You'll need to write a plugin to override the default configuration with one that enables CORS: https://github.com/Teradata/kylo/blob/v0.8.4/services/service-app/src/main/java/com/thinkbiganalytics/server/DefaultWebSecurityConfigurer.java

0
On

Finally I decided to create a Proxy web service which is hosted in the same server as Kylo, which just redirects the requests from the web to the Kylo Service.