Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save WagnerMoreira/0ccb1b41d5a9b621fc33 to your computer and use it in GitHub Desktop.
Save WagnerMoreira/0ccb1b41d5a9b621fc33 to your computer and use it in GitHub Desktop.
Populating AngularJS's resource URL whitelist enables the use of remotely located views and partials hosted on a different domain (e.g., Amazon S3).
/*
* Standard AngularjS bootstrap code.
*/
var app = angular.module('remote-partials-views',
['ui.router',
'ngResource',
'ngSanitize']);
/*
* AngularJS is good enough to come with a whitelist for resource URLs. It just
* needs to be populated. It's pretty straightforward, as it's a simple array
* list of whitelisted values. You might notice the first entry is "self." This
* is just shorthand for whatever domain the AngularJS site is executing on.
*/
app.config(['$sceDelegateProvider', function($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhitelist([
'self',
'https://remote.domain.com/**'
]);
}]);
@hetdev
Copy link

hetdev commented Jul 18, 2016

nice, thanks!

@muminvarici
Copy link

Thank you, that works for me.

@avandermeyden
Copy link

avandermeyden commented Nov 3, 2017

Pro Tip: It seems these URLs only match if they are added using lower-case as above. (I'm on Angular 1.4.2 so perhaps that restriction has been relaxed in later versions).

@bdsi-tn
Copy link

bdsi-tn commented Apr 20, 2020

Please how can i use the angularjs-scedelegate-whitelist, where must i put this file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment