【问题标题】:Brightcove: CORS error using Play-Framework 2.3.x and Angular-JSBrightcove:使用 Play-Framework 2.3.x 和 Angular-JS 的 CORS 错误
【发布时间】:2015-07-13 16:47:11
【问题描述】:

我在我的示例应用程序中使用brightcove 来管理视频。我的示例应用程序基于Play-Framework 2.3.xScalaAngular-JS。问题是,我使用Angular-JS 使用Brightcove apis 将视频上传到brightcove 服务器。我的 Angular 代码如下:

 $scope.uploadProcess=   $upload.upload({
          url: 'http://api.brightcove.com/services/post',
          headers: {
            'Content-Type': file.type
          },
          method: 'POST',
          fields: {
        "method": "create_video", 
      "params": {
       "video": {
           "name": filename,
           "tags": [],
           "shortDescription": filename,
           "itemState": "ACTIVE"
          },
  -------------------------------------------

当我发送请求时,浏览器在响应时返回以下错误。

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://api.brightcove.com/services/post. This can be fixed by moving the resource to the same domain or enabling CORS.

通过在 Google 上搜索,我找到了一些解决方案,例如 Call Play 2 REST API with AngularJS (CORS Problems)。但没有任何工作。我真的被困在那种情况下,请提供解决方案。提前致谢。

【问题讨论】:

    标签: angularjs scala playframework-2.3 brightcove


    【解决方案1】:

    如果您想从浏览器执行此类请求,您需要确保在服务器上启用了 CORS。

    Brightcove 似乎没有启用该功能,至少错误消息说明是这样的。

    最简单的解决方案可能是通过后端发布文件。

    【讨论】:

      猜你喜欢
      • 2014-12-23
      • 2014-09-28
      • 2015-12-09
      • 2018-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-26
      相关资源
      最近更新 更多