You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to provide custom headers with every API call made by the Angular Report Viewer. My goal is to add an authorization token. I add the custom header via the interceptor `token-http-interceptor.service.ts`. However, the header is not added to the calls made by the Angular Report Viewer.
31
+
This article explains how to include HTTP headers—such as authorization tokens—in the REST API requests made by HTML5-based report viewers.
32
32
33
-
## Solution
33
+
It applies to the following viewers:
34
34
35
-
The Angular Report Viewer is a wrapper of the HTML5 Report Viewer, which is a jQuery widget and not a native Angular component. That's why you cannot add custom headers the Angular way - via the HTTP interceptor. In this article, we suggest two possible solutions.
The Angular Report Viewer comes with out-of-the-box support for an [*authenticationToken* option]({%slug telerikreporting/using-reports-in-applications/display-reports-in-applications/web-application/angular-report-viewer/api-reference/options%}). This option adds an `Authorization` header for every request to the REST service.
44
+
All HTML5-based report viewers support an authentication token configuration option that automatically appends a `Bearer` token to the `Authorization` header of each request sent to the Telerik Reporting REST service. For example, the HTML5 Report Viewer includes an [`authenticationToken` option]({%slug telerikreporting/using-reports-in-applications/display-reports-in-applications/web-application/html5-report-viewer/api-reference/report-viewer-initialization%}).
40
45
41
-
### Solution 2
46
+
>note The exact casing or naming of this option may vary across different viewer implementations. For accurate usage, refer to the specific documentation for the viewer you are integrating.
42
47
43
-
The second solution is to add the custom headers to the REST API calls of the Angular Report Viewer with *jQuery's*[ajaxSetup](https://api.jquery.com/jquery.ajaxsetup/) function:
48
+
## Solution 2
44
49
45
-
The following code represents one possible approach that can be used in the component with the Angular report viewer:
50
+
>note In both cases, ensure that the TS/JS code is executed before the report viewer is initialized, so that the overridden fetch logic takes effect during the initialization process.
46
51
52
+
The second solution is to add custom headers to the REST API calls of the HTML5 report viewer. Based on the version you are on, you can follow either of these approaches:
53
+
54
+
### Telerik Reporting Q2 2025+
55
+
56
+
Starting from `19.1.25.521`, the HTML5-based report viewers rely on the browser's built-in [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) to issue their requests to the Reporting REST service. To add custom HTTP headers to the requests, you can override the [window.fetch() method](https://developer.mozilla.org/en-US/docs/Web/API/Window/fetch) as follows:
57
+
58
+
````TypeScript
59
+
const originalFetch =window.fetch;
60
+
61
+
window.fetch=asyncfunction (
62
+
input:RequestInfo|URL,
63
+
init?:RequestInit
64
+
):Promise<Response> {
65
+
66
+
const headers =newHeaders(init?.headers|| {});
67
+
68
+
if (typeofinput==="string"&&input.includes('api/reports')) {
Before the [2025Q2 release](https://www.telerik.com/support/whats-new/reporting/release-history/progress-telerik-reporting-2025-q2-19-1-25-521), the report viewer implementation relied on jQuery-based requests. To add custom HTTP headers in this scenario, you can use jQuery's [ajaxSetup()](https://api.jquery.com/jquery.ajaxsetup/) function:
0 commit comments