【问题标题】:Angular ng build --prod causes blank screen in browserAngular ng build --prod 导致浏览器出现黑屏
【发布时间】:2018-03-08 07:44:12
【问题描述】:

当运行 ng build --prod 命令并在浏览器中加载应用程序时,通常从服务器检索的所有元素都不会显示

这是一个 dotnet core 2.0 项目,前端是 Angular 5 我正在使用“@auth0/angular-jwt”:“^1.0.0-beta.9”

如果我浏览到页面上的链接,我会收到错误消息

main.23ac97c628174ee61247.bundle.js:1 ERROR TypeError: Failed to construct 
'URL': Invalid URL
  at t.isWhitelistedDomain (main.23ac97c628174ee61247.bundle.js:1)
  at t.handleInterception (main.23ac97c628174ee61247.bundle.js:1)
  at t.intercept (main.23ac97c628174ee61247.bundle.js:1)
  at t.handle (main.23ac97c628174ee61247.bundle.js:1)
  at t.intercept (main.23ac97c628174ee61247.bundle.js:1)
  at t.handle (main.23ac97c628174ee61247.bundle.js:1)
  at t.handle (main.23ac97c628174ee61247.bundle.js:1)
  at e.project (main.23ac97c628174ee61247.bundle.js:1)
  at e._tryNext (main.23ac97c628174ee61247.bundle.js:1)
  at e._next (main.23ac97c628174ee61247.bundle.js:1)

app.module.ts:

export function getAccessToken(): string {
  return localStorage.getItem('token');
}

export const jwtConfig = {
  tokenGetter: getAccessToken,
  whiteListedDomains: ['localhost:5000']
};

  imports: [
    JwtModule.forRoot({
      config: jwtConfig
     }),

【问题讨论】:

    标签: angular jwt


    【解决方案1】:

    这是一个未解决的问题:https://github.com/auth0/angular2-jwt/issues/477

    问题是通过使用相对 url 调用 new URL(request.url) 在 lib 内部引起的。您可以在没有 ^ 的情况下在 package-json 中设置您的版本,因为 beta 9 应该可以工作或通过删除相对 url 调用。

    你也拼错了 whitelistedDomains

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-02-28
      • 1970-01-01
      • 1970-01-01
      • 2020-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多