Client Side JS Report without Login
-
I'm using the JS Report on the client side .
<script> function myFunction() { var data = data jsreport.serverUrl = 'http://localhost:5000'; var request = { template: { shortid: "HJBAIagmN" }, data: data }; jsreport.render('_blank', request); }; </script>
My doubt was , how can i get the report from the JSreport when the auth is enabled in the JS Report server ( studio) .
Since , every time the function runs , the login screen is popped & after the login the report is loaded.How can i
-
keep the auth / login in the studio
-
but the request from the client side can get report without login.
Any possible ways .
-
-
Please see this snipped from the documentation
https://jsreport.net/learn/browser-clientIt shows how you can add authorization header to the
renderAsync
calls.
Note that therender
function doesn't support adding auth header.//add custom headers to ajax calls jsreport.headers['Authorization'] = "Basic " + btoa("admin:password") //render through AJAX request and return promise with array buffer response jsreport.renderAsync(request).then(function(res) { console.log(res); //open in new window window.open(res.toDataURI()) //get the content as string res.toString() //open download dialog res.download('test.pdf') });