Angular 2中的Fetch.js抱怨CORS请求

Fat*_*sis 2 javascript express angular

我模糊地按照快速入门教程设置并在与expressjs后端通信的应用程序中使用angular 2.我已经解决了一些依赖问题并解决了大部分依赖问题,但我陷入困境.我遇到的错误是:

Fetch API cannot load npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js. URL scheme must be "http" or "https" for CORS request.
Run Code Online (Sandbox Code Playgroud)

我的systemjs.config.js文件是他们的快速入门中指定的文字.

(function(global) {
    System.config({
        paths: {
            'npm': 'node_modules/'
        },

        map: {
            app: 'app',

            // angular bundles
            '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
            '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
            '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
            '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
            '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
            '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
            '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
            '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',

            // other libraries
            'rxjs':                      'npm:rxjs',
            'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js'
        },

        // packages tells the System loader how to load when no filename and/or no extension
        packages: {
            app: {
                defaultExtension: 'js'
            },
            rxjs: {
                defaultExtension: 'js'
            }
        }
    });
})(this);
Run Code Online (Sandbox Code Playgroud)

我遇到的很多问题都是通过在expressjs脚本中指定正确的静态路径来解决的.令我困惑的是为什么只有那个文件(platform-b​​rowser-dynamic.umd.js)被认为是一个CORS请求.我已经确认它存在于指定的目录中,所以这不是问题.有没有人对此有任何见解?(目前大多数客户端来源都是他们的快速入门,如果你认为它是相关的,只要问一下,我就会发布它).

Fat*_*sis 9

排除故障4小时,厌倦了,发布问题,稍后找到答案.

这是一个错字.显然,如果您指定的路径尚未指定并且是未知协议的脚本,它将尝试将其视为CORS请求.

我有什么:

path: {
    'npm': 'node_modules/'
}
Run Code Online (Sandbox Code Playgroud)

应该是什么:

path: {
    'npm:': 'node_modules/'
}
Run Code Online (Sandbox Code Playgroud)