Dhruvan Ganesh
Dhruvan Ganesh

Reputation: 1580

Does SonarQube support JSONP?

I'm working on a WebApp which cannot retrieve data from the SonarQube server because the browser complains that No 'Access-Control-Allow-Origin' header is present on the requested resource. After searching the recommended way to overcome this error is to use JSONP or CORS. I'm unable to find documentation regarding JSONP callbacks. Is this feature part of the SonarQube server?

Alternative solution I found to solve this problem

Going with a reverse proxy to process API requests and serve it with CORS headers. Using the cors-anywhere package to do this.

Upvotes: 0

Views: 127

Answers (2)

surekha  shelake
surekha shelake

Reputation: 246

NOTE: for below ways you will require CROSS ORIGIN POLICTY ALLOW

there is way to fetch SonarQube data remotely.

  1. you can try fecthing data by CURL. e.g curl -u MY_LOGIN:MY_PASSWORD https://sonarqube.com/api/user_tokens/search

    • replace your sonarqube sever details it will fetch data of list of user tokes for user.
  2. if you are using node server with angular js, you can write module with basic authentication will hit apis you want. refer doc: https://docs.sonarqube.org/pages/viewpage.action?pageId=2752802 e.g - to fetch list of project on system api is http://yourservername/api/resources

Hope it will help you.

Upvotes: -1

If you want to get data from a remote SonarQube server and serve it in a web application, the only way for the moment is to fetch it on backend side and then pass the result to your frontend.

Upvotes: 2

Related Questions