2017-03-10 54 views
1

我们的项目有一个Angular 2客户端与服务器上的ASP.NET Web API进行交互。当Froala发出HTTP请求时,将令牌添加到HTTP标头

当我们在配置Froala编辑器的实例,以允许图像上传,我们有我们的角2组件的以下设置:

$(function() { 
 
      $('div#ed' + divid).froalaEditor({ 
 
       heightMin: 100, 
 
       toolbarInline: false, 
 
       widthMin: 100, 
 
       imageUploadURL: 'http://something.com:8067/FroalaApi/UploadImage', 
 
       toolbarButtons: ['bold', 'underline', 'strikeThrough', 'subscript', 'superscript', 'fontFamily', 'fontSize', '|' 
 
        , 'align', 'undo', 'redo', 'selectAll', '|', 'insertImage'], 
 
       toolbarButtonsXS: ['undo', 'redo', '-', 'bold', 'italic', 'underline'], 
 
       //toolbarVisibleWithoutSelection: true, 
 
       pluginsEnabled: null, 
 
       charCounterCount: false 
 
      }) 
 
     });

正如你所看到的,我们正在调用绝对URL而不是相对URL(如示例中所示)。 现在,Froala编辑器会对此URL的AJAX调用发送请求并获取响应(链接到图像)并将其显示在编辑器中。

当Froala发送此请求时,我们可以修改HTTP请求标头吗?问题在于API需要身份验证令牌,并且由于缺少,我们无法集成。编辑器是否接受函数作为属性,然后可以代表它发出HTTP请求?

回答