Pentaho 7.1 CE 中的 CORS 错误
CORS Error in Pentaho 7.1 CE
我正在尝试将 Pentaho 7.1 CE 版本与 Angular 应用程序集成,并且我必须访问 Pentaho 上下文。出于此处的身份验证目的,我使用基于 cookie 的 API 并传递参数。在此期间,我收到以下错误:
XMLHttpRequest cannot load
http://localhost:8083/pentaho/j_spring_security_check. Redirect from
'http://localhost:8083/pentaho/j_spring_security_check' to
'http://localhost:8083/pentaho/Home;jsessionid=E0B8FFAFE57EDEC09DB8229457FAA7B4'
has been blocked by CORS policy: No 'Access-Control-Allow-Origin'
header is present on the requested resource. Origin
'http://localhost:4200' is therefore not allowed access.
我已经在 Pentaho 中启用了 CORS 并修改了位于
pentaho-server\tomcat\conf
:
的 web.xml
文件
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
<init-param>
<param-name>cors.allowed.origins</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.methods</param-name>
<param-value>GET,POST,HEAD,OPTIONS,PUT</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.headers</param-name>
<param-value>Content-Type,X-Requested-With,accept,Origin,Access-Control-Allow-Origin,Access-Control-Request-Method,Access-Control-Request-Headers</param-value>
</init-param>
<init-param>
<param-name>cors.exposed.headers</param-name>
<param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>
</init-param>
<init-param>
<param-name>cors.support.credentials</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>cors.preflight.maxage</param-name>
<param-value>10</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
任何人都可以向我建议我在这里缺少什么吗?知道如何解决这个问题吗?
当我尝试创建一个 webapi 并从 Angular2 网络应用程序使用它时,我遇到了同样的问题。我通过从 https://www.nuget.org/packages/Microsoft.AspNet.WebApi.Cors 安装 nuget 来修复它
在 webapi 解决方案中。有一个 how-to-use explanation 的 nuget
这对我来说很好。
我正在尝试将 Pentaho 7.1 CE 版本与 Angular 应用程序集成,并且我必须访问 Pentaho 上下文。出于此处的身份验证目的,我使用基于 cookie 的 API 并传递参数。在此期间,我收到以下错误:
XMLHttpRequest cannot load http://localhost:8083/pentaho/j_spring_security_check. Redirect from 'http://localhost:8083/pentaho/j_spring_security_check' to 'http://localhost:8083/pentaho/Home;jsessionid=E0B8FFAFE57EDEC09DB8229457FAA7B4' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.
我已经在 Pentaho 中启用了 CORS 并修改了位于 pentaho-server\tomcat\conf
:
web.xml
文件
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
<init-param>
<param-name>cors.allowed.origins</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.methods</param-name>
<param-value>GET,POST,HEAD,OPTIONS,PUT</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.headers</param-name>
<param-value>Content-Type,X-Requested-With,accept,Origin,Access-Control-Allow-Origin,Access-Control-Request-Method,Access-Control-Request-Headers</param-value>
</init-param>
<init-param>
<param-name>cors.exposed.headers</param-name>
<param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>
</init-param>
<init-param>
<param-name>cors.support.credentials</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>cors.preflight.maxage</param-name>
<param-value>10</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
任何人都可以向我建议我在这里缺少什么吗?知道如何解决这个问题吗?
当我尝试创建一个 webapi 并从 Angular2 网络应用程序使用它时,我遇到了同样的问题。我通过从 https://www.nuget.org/packages/Microsoft.AspNet.WebApi.Cors 安装 nuget 来修复它 在 webapi 解决方案中。有一个 how-to-use explanation 的 nuget 这对我来说很好。