AngularJS issue: $sce:insecurl despite $sce.trustAsResourceUrl

113 views Asked by At

I have a set-up using templates from my CDN, that usually works fine but periodically I get this error:

ng-error: Error: [$sce:insecurl] http://errors.angularjs.org/1.7.5/$sce/insecurl?p0=https%3A%2F%2Fcomplicemail-herokuapp-com.global.ssl.fastly.net%2Fstatic%2Ftemplates%2Fviewschedule.a15ce4bf.html

I grepped the codebase for viewsched, and literally the only two places in the code where that template are my precache list in my service worker, and this line in the angularjs file:

$scope.scheduleTemplateUrl = $sce.trustAsResourceUrl('/templates/viewschedule.html')

Gulp turns that line into the one that references the CDN:

$scope.scheduleTemplateUrl = $sce.trustAsResourceUrl('https://complicemail-herokuapp-com.global.ssl.fastly.net/static/templates/viewschedule.a15ce4bf.html')

I know that part's working because the insecurl error shows the CDN url.

My first guess that the issue is something like "for whatever reason (eg shoddy internet) the browser couldn't connect with the CDN at that moment and failed to fetch the file, giving some sort of HTTP response code that AngularJS considers insecure. But I think that would produce this issue (which I also periodically get)

ng-error: Error: [$templateRequest:tpload] http://errors.angularjs.org/1.7.5/$templateRequest/tpload?p0=https%3A%2F%2Fcomplicemail-herokuapp-com.global.ssl.fastly.net%2Fstatic%2Ftemplates%2Ftimer%2Fuser-other.27734af8.html&p1=-1&p2=

Any ideas? Also interested in ideas for how to more gracefully handle the tpload error situation in cases like this where the url is correct but the internet just conked out at that moment.

0

There are 0 answers