From 5a7ac8c3b95e97cd080783bc85d7e7eaad87f78a Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Tue, 17 Mar 2020 22:28:36 +0200 Subject: [PATCH] build(docs-infra): avoid Karma error when loading scripts from code.angularjs.org (#36015) In the example apps used in the `ngUpgrade` guide, the AngularJS files are loaded in `index.html` from `https://code.angularjs.org/`. Latest browsers prevent loading the scripts from a page running on localhost due to CORS: ``` Access to script at 'https://code.angularjs.org/1.5.5/angular.js' from origin 'http://localhost:9876' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. ``` NOTE: Loading the files from `code.angularjs.org` is not mentioned in the guide, therefore it is not needed to mention this config change there. PR Close #36015 --- .../upgrade-phonecat-1-typescript/karma.conf.ajs.js | 9 +++++++++ .../upgrade-phonecat-2-hybrid/karma.conf.ajs.js | 13 +++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/aio/content/examples/upgrade-phonecat-1-typescript/karma.conf.ajs.js b/aio/content/examples/upgrade-phonecat-1-typescript/karma.conf.ajs.js index dc829d1983..89d9e7bcd7 100644 --- a/aio/content/examples/upgrade-phonecat-1-typescript/karma.conf.ajs.js +++ b/aio/content/examples/upgrade-phonecat-1-typescript/karma.conf.ajs.js @@ -16,6 +16,15 @@ module.exports = function(config) { '**/*.spec.js' ], + // This is needed, because the AngularJS files are loaded from `https://code.angularjs.org/`. + // Without this, latest browsers prevent loading the scripts from localhost with: + // ``` + // Access to script at 'https://code.angularjs.org/1.5.5/angular.js' from origin + // 'http://localhost:9876' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' + // header is present on the requested resource. + // ``` + crossOriginAttribute: false, + autoWatch: true, frameworks: ['jasmine'], diff --git a/aio/content/examples/upgrade-phonecat-2-hybrid/karma.conf.ajs.js b/aio/content/examples/upgrade-phonecat-2-hybrid/karma.conf.ajs.js index 213834b1aa..699b5075f7 100644 --- a/aio/content/examples/upgrade-phonecat-2-hybrid/karma.conf.ajs.js +++ b/aio/content/examples/upgrade-phonecat-2-hybrid/karma.conf.ajs.js @@ -44,12 +44,21 @@ module.exports = function(config) { // #enddocregion files ], + // This is needed, because the AngularJS files are loaded from `https://code.angularjs.org/`. + // Without this, latest browsers prevent loading the scripts from localhost with: + // ``` + // Access to script at 'https://code.angularjs.org/1.5.5/angular.js' from origin + // 'http://localhost:9876' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' + // header is present on the requested resource. + // ``` + crossOriginAttribute: false, + // #docregion html // proxied base paths for loading assets proxies: { // required for component assets fetched by Angular's compiler - "/phone-detail": '/base/app/phone-detail', - "/phone-list": '/base/app/phone-list' + '/phone-detail': '/base/app/phone-detail', + '/phone-list': '/base/app/phone-list' }, // #enddocregion html