Django的1.6 + AngularJS V1.2.6 +亚马逊AWS [英] Django 1.6 + AngularJS v1.2.6 + Amazon Aws

查看:186
本文介绍了Django的1.6 + AngularJS V1.2.6 +亚马逊AWS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,整合的角度我现有的Django应用,我已经设置好的亚马逊AWS与宝途的静态文件,但使用AngularJs当我得到这个错误:

I have a problem integrating my existing django app with angular, I have setted Amazon AWS with Boto for the static files, but when using AngularJs i get this error:

阻止加载资源不被$ sceDelegate政策允许的。网址:

所以,我调查,并试图做到这一点:

So I investigated and tried to do this:

$sceDelegateProvider.resourceUrlWhitelist(['self',djangoStaticURL]);

在我的模块的配置,但dopesn't似乎工作,所以我尝试:

On my module config but dopesn't seem to work, so I tried:

templateUrl: $sceProvider.trustAsResourceUrl(djangoStaticURL + 'app/views/main.html'),

和得到$ SCE提供者没有定义,这是我的完整模块:

And get $sce provider not defined, this is my complete module:

angular.module('portfolioApp', [
  'ngCookies',
  'ngResource',
  'ngSanitize',
  'ngRoute',
  'portfolioApp.filters',
]).config(function ($sce ,$routeProvider, $sceDelegateProvider) {
  $sceDelegateProvider.resourceUrlWhitelist(['self',djangoStaticURL]);
  $routeProvider
    .when('/', {
      templateUrl: $sce.trustAsResourceUrl(djangoStaticURL + 'app/views/main.html'),
      //templateUrl: djangoStaticURL + 'app/views/main.html',
      controller: 'MainCtrl'
    })
    .otherwise({
      redirectTo: '/'
    });
});

因此​​,这是一个坏主意?我应该做的Django的所有路由?或者是有什么我-M失踪?

So is this a bad idea ? should I do all the routing from django ? or is there something I-m missing?

推荐答案

我终于编辑AWS CORS的配置是这样解决的:

I finally solved this by editing AWS CORS configuration like this:

选择你的水桶在您的静态文件 选择属性 选择编辑CORS的配置

Select your bucket where your static files are Select Properties Select Edit CORS configuration

粘贴这样的事情

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <CORSRule>
        <AllowedOrigin>http://arlefreak.herokuapp.com/</AllowedOrigin>
        <AllowedMethod>PUT</AllowedMethod>
        <AllowedMethod>POST</AllowedMethod>
        <AllowedMethod>DELETE</AllowedMethod>
        <AllowedHeader>*</AllowedHeader>
    </CORSRule>
    <CORSRule>
        <AllowedOrigin>http://*.arlefreak.com/</AllowedOrigin>
        <AllowedMethod>PUT</AllowedMethod>
        <AllowedMethod>POST</AllowedMethod>
        <AllowedMethod>DELETE</AllowedMethod>
        <AllowedHeader>*</AllowedHeader>
    </CORSRule>
    <CORSRule>
        <AllowedOrigin>*</AllowedOrigin>
        <AllowedMethod>GET</AllowedMethod>
    </CORSRule>
</CORSConfiguration>

在更多信息: HTTP://docs.aws.amazon。 COM / AmazonS3 /最新的/ dev / cors.html

这篇关于Django的1.6 + AngularJS V1.2.6 +亚马逊AWS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆