How to Add Headers to AJAX Requests in JavaScript (ES5) PDF Viewer

14 Aug 20261 minute to read

Use the ajaxHeaders property inside the PDF Viewer’s ajaxRequestSettings to send custom HTTP headers with each request made by the viewer.

Example: Add a custom Authorization header using ajaxRequestSettings in a JavaScript component

viewer.ajaxRequestSettings = {
   ajaxHeaders: [
      {
         headerName: "Authorization",

         headerValue: "Bearer 64565dfgfdsjweiuvbiuyhiueygf"
      }
   ],

   withCredentials: false
};

Sample: How to add custom headers using ajaxRequestSettings
StackBlitz example