代码之家  ›  专栏  ›  技术社区  ›  The One

角度CLI+角度2 JWT错误

  •  0
  • The One  · 技术社区  · 7 年前
    1. 我使用Angular CLI生成了一个应用程序。
    2. 在终端中运行“npm install angular2 jwt”
    3. 将脚本引用添加到angular cli。json:

      "scripts":[
         ...
           "../node_modules/angular2-jwt/angular2-jwt.js"
         ...
       ]    
      
    4. “ng serve”至今没有问题

    5. http://localhost:4200 我得到:
        caught ReferenceError: require is not defined at scripts.bundle.js:224 (anonymous) @ scripts.bundle.js:224
    

    enter image description here

    我不想在出现这个错误的情况下继续实现angular2 JWT。 我怎样才能解决这个问题?

    1 回复  |  直到 7 年前
        1
  •  0
  •   The One    7 年前

    我找不到答案,实际上有一个 issue 在Github上打开这个,未解决。

    所以我发现 this manual implementation of JWT authentication for the client

    其想法只是从服务器检索令牌,将其存储在本地存储器中,然后在每个请求中将其作为头发送。