Skip to main content
TMauran
Silver ⭐️⭐️⭐️
Aug 1, 2024 3:45 PM UTC
Question

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

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

cloude
Gold ⭐️
Gold ⭐️
Aug 2, 2024 10:34 AM UTC

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

Translate
TMauran
TMauranAuthor
Silver ⭐️⭐️⭐️
Aug 2, 2024 12:42 PM UTC

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 ?

Translate
cloude
Gold ⭐️
Gold ⭐️
Aug 3, 2024 4:23 AM UTC

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

Translate
cloude
Gold ⭐️
Gold ⭐️
Aug 5, 2024 2:13 AM UTC

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

Translate
TMauran
TMauranAuthor
Silver ⭐️⭐️⭐️
Aug 5, 2024 7:01 AM UTC

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

Translate