JavaFX WebView disable Same origin policy (allow cross domain requests)

点点圈 提交于 2019-12-01 04:05:16

Basically, javaFx has the issue which is coupled with CORS - https://javafx-jira.kenai.com/browse/RT-35868. Assuming that web services which you are using, have CORS enabled you can try the following approach:

  • System.setProperty("sun.net.http.allowRestrictedHeaders", "true")

OR

  • java -Dsun.net.http.allowRestrictedHeaders=true <your main class here>

Hope it will help you

lysium

Since you are already running in JavaFX as a desktop application, you can do your JavaScript call via Java, where the same-origin policy does not apply.

Alternatively, this answer to the SO question you've posted seems to be a viable alternative.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!