gpt4 book ai didi

angular - 如何在 Webhdfs - HDFS - Hadoop - Origin http ://localhost:4200 is not allowed by Access-Control-Allow-Origin 中启用 cors origin allow

转载 作者:可可西里 更新时间:2023-11-01 15:21:18 32 4
gpt4 key购买 nike

当我尝试从我的 Angular 6 应用程序访问 Webhdfs 时,我收到如下所示的错误。在我看来,我几乎尝试了所有方法,包括更改 core-site.xmlhdfs-site.xml 中的设置,不幸的是没有得到积极的结果。显然,很可能需要正确配置 Hadoop。有谁知道我该如何解决这个问题?

[Error] Origin http://localhost:4200 is not allowed by Access-Control-Allow-Origin.
[Error] XMLHttpRequest cannot load http://192.168.0.16:9870/webhdfs/v1/user/myuser/myfile.csv?op=CREATE&user.name=myuser&createflag=&createparent=true&overwrite=false due to access control checks.
[Error] Failed to load resource: Origin http://localhost:4200 is not allowed by Access-Control-Allow-Origin. (myfile.csv, line 0)

最佳答案

来自docs :

To enable cross-origin support (CORS), please set the following configuration parameters:

Add org.apache.hadoop.security.HttpCrossOriginFilterInitializer to hadoop.http.filter.initializers in core-site.xml. You will also need to set the following properties in core-site.xml -

hadoop.http.cross-origin.enabled = true

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

hadoop.http.cross-origin.allowed-methods = GET、POST、HEAD、DELETE、OPTIONS

hadoop.http.cross-origin.allowed-headers = X-Requested-With,Content-Type,Accept,Origin

hadoop.http.cross-origin.max-age = 1800

关于angular - 如何在 Webhdfs - HDFS - Hadoop - Origin http ://localhost:4200 is not allowed by Access-Control-Allow-Origin 中启用 cors origin allow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52768514/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com