【问题标题】:Trouble serving Auth0 dependencies on client with SystemJS无法使用 SystemJS 在客户端上提供 Auth0 依赖项
【发布时间】:2017-01-20 02:18:16
【问题描述】:

我有一个基于 Angular2 和 Express 的网络应用程序。我正在尝试实现一个安全的 API 端点,并且正在作弊并使用 Auth0。我正在关注guide,但是,我的设置似乎并没有进展。我的应用目前正在崩溃:

GET /angular2-jwt 404 30.433 毫秒 - 14

尽管我有这个system.config.js:

(function (global) {
  System.config({
    paths: {
      'npm:': 'node_modules/'
    },
    map: {
      app: 'app',
      '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
      //all the other angular packages
      'angular2-jwt':               'node_modules/angular2-jwt/angular2-jwt.js',
      'rxjs':                       'npm:rxjs',
      'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api'
    },
    packages: {
      app: {
        main: './main.js',
        defaultExtension: 'js'
      },
      rxjs: {
         main: 'Rx.js',
        defaultExtension: 'js'
      },
      'angular2-in-memory-web-api': {
        main: './index.js',
        defaultExtension: 'js'
      },
      'angular2-jwt': { defaultExtension: 'js' }
    }
  });
})(this);

为什么我的 system.config.js 不工作,或者我是否误解了如何使用 systemJS?

我的 index.html 包含:

<script src="./config/systemjs.config.js"></script>
<script>
  System.import('app').catch(function(err){ console.error(err); });
</script>

如果我在 system.config 的 System.config({ 行的正上方添加一条 console.log 消息,它不会被触发。这是否意味着我的 system.config 没有被读取?

【问题讨论】:

    标签: express systemjs auth0


    【解决方案1】:

    你在 system.config.js 中有错字:

      'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api'
    },no extension
    packages: {
    

    当我删除 no extension 时,它会按预期请求

    GET /node_modules/angular2-jwt/angular2-jwt.js
    

    如果我在 System.config({ 我的 system.config 行的正上方添加一条 console.log 消息,它不会被触发。这是否意味着我的 system.config 没有被读取?

    很可能,是的。您可以通过查看浏览器中开发人员工具中的网络活动选项卡来检查它 - 应该有一个获取 systemjs.config.js 的请求。

    您可以在 https://github.com/fictitious/test-systemjs-angular 找到一个使用导入的示例(但是它不进行任何身份验证)。

    【讨论】:

    • 恐怕这是问题中的错字(仅部分删除了评论),并不是我面临的问题的原因。我的错 - 对不起。
    • 那个 system.config.js 正在工作 - 请参阅 github.com/fictitious/test-systemjs-angular 。问题不在 systemjs 配置中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-17
    • 2019-03-23
    • 2015-01-02
    • 1970-01-01
    • 1970-01-01
    • 2016-10-21
    • 2021-10-19
    相关资源
    最近更新 更多