How to enable CORS for SonarQube

I am trying to call one of Sonar web services through jQuery. Since the call passes through the domain, the call is interrupted in Chrome with the following error: No header "Access-Control-Allow-Origin" is present on the requested resource. Does anyone know how to enable CORS on a SonarQube server? I am using SonarQube 4.3. I even tried adding a filter to sonarqube-4.3 \ web \ WEB-INF \ web.xml, but that didn't help. Any help would be appreciated.

<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-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>

Thanks Sarah

+4
source share
1 answer

I hit the same issue.

, resetUnhandledResponse RackFilter false web.xml .

CORS , , , .

<filter>
 <filter-name>RackFilter</filter-name>
 <filter-class>org.jruby.rack.RackFilter</filter-class>
 <init-param>
    <param-name>resetUnhandledResponse</param-name>
    <param-value>false</param-value> <!-- true (default), false or buffer -->
 </init-param>
</filter>
+3

Source: https://habr.com/ru/post/1547502/


All Articles