Support Questions

Find answers, ask questions, and share your expertise

Spark History CORS header ‘Access-Control-Allow-Origin’ missing

avatar
Contributor

Hello,
I'm trying to acces Spark History UI through Apache Knox proxy but I get this error the following error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://<spark-host>:18080/api/v1/applications?limit=2147483647&status=completed. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 302.

I can' t find something related to CORS in Spark do you know how I could fix that ?

Thanks for your answer

5 REPLIES 5

avatar
Contributor

@TMauran
If you're using firefox, turn off enhanced tracking protection. 

avatar
Contributor

Hello @cloude thank you for your answer, I disabled it and still got the error, tried on chrome too here is the error message in chrome,

Access to XMLHttpRequest at 'https://spark-host:18080/api/v1/applications?limit=2147483647&status=completed' from origin 'https://knox-host:8443' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Do you have any other idea ?

avatar
Contributor

Can you try setting below properties and restart history server ?

History Server Advanced Configuration Snippet (Safety Valve) for spark-conf/spark-history-server.conf"

spark.hadoop.http.cross-origin.allowed-origins = *

spark.hadoop.http.cross-origin.allowed-methods = GET, PUT, POST, OPTIONS, HEAD, DELETE

spark.hadoop.http.cross-origin.allowed-headers = X-Requested-With, Content-Type, Accept, Origin, WWW-Authenticate, Accept-Encoding, Transfer-Encoding

spark.hadoop.http.cross-origin.max-age = 180

avatar
Contributor

@TMauran Let me know if its resolve, please accept as solution so that it will be helpful for others as well.

avatar
Contributor

Hello @cloude even after adding those parameters I get the 302 error, wondering if the issue is not on the Knox part though now but thank you very much for your answer