angular - Syncfusion Angular PDF Viewer Control - Passing Headers Along
问题描述
We use token-authentication on our endpoints and when viewing a PDF I'd like to use the standard Syncfusion implementation approach but want to know if it's possible to pass headers along with the request. I've ask the question on their forums but I'm aware that feedback can take a bit long.
I see that its possible with their "Uploader control implementation"
解决方案
We can add Authorization header to the PDF Viewer control’s AJAX request in the sample level. Kindly include the below code in ngOnInit()
of TS file,
ngOnInit(): void {
(<any> XMLHttpRequest).prototype.realSend = XMLHttpRequest.prototype.send;
var newSend = function (vData) {
this.setRequestHeader('Authorization', 'Bearer 64565dfgfdsjweiuvbiuyhiueygf');
this.realSend(vData);
};
XMLHttpRequest.prototype.send = newSend;
}
The XMLHttpRequest’s method setRequestHeader()
, adds custom HTTP headers to the request.
We have created the sample for the same and shared in the following location, https://www.syncfusion.com/downloads/support/directtrac/general/ze/my-app_Authentication1715968051
Please find the below KB link for reference, https://www.syncfusion.com/kb/10334/how-to-add-anti-forgery-token-to-the-pdfviewercontrol
Please try this and let us know if you have any concerns on this.
Regards, Akshaya
推荐阅读
- javascript - API 结果说它是空的,但它不是
- node.js - 无法通过 id 找到文档
- webdriver-io - 在调用 browser.getTabIds() 时获取“browser.getTabIds”不是 webdriverio 中的函数
- python - 根据标记颜色过滤叶图
- java - 弹簧断路器 - Resilience4j - 如何配置?
- nginx - 具有集群 IP 服务和默认 nginx 的 kubernetes 入口控制器未按预期工作
- javascript - 如何在最近的标签中找到类?
- javascript - 不为空时禁用输入字段,如果为空则启用它不起作用
- sas - 在 sas 中查找新用户和重复用户
- haskell - 确定数据类型实例的构造函数