Reputation: 221
Using NodeJS, is it possible to listen to calls from localhost:3000
to my.site.com/resources/*
and serve those files locally instead ?
Context: my Angular app relies on resources from a CDN. Sometimes when the CDN is down, I want to serve these files locally.
Upvotes: 0
Views: 121
Reputation: 46
You can use javascript to check if angular object is correctly loaded , if not you generate a new tag a local link instead of CDN
<script src="//cdn_link/angular.min.js"></script>
<script>
(typeof angular != 'undefined') || document.write('<script src="local_link/angular.min.js")<\/script>')
</script>
For angular2 you can check for ng object instead of angular
Upvotes: 1