Type '' is not assignable to type 'JwtConfig'

ros*_*osa 4 jwt typescript google-oauth angular

I need to put those line into my code. but this error keeps appearing and I'm stuck with this, being not able to find the solution. Please help me.

Type '{ tokenGetter: () => string; whitelistedDomains: string[]; blacklistedRoutes: undefined[]; }' is not assignable to type 'JwtConfig'. Object literal may only specify known properties, and 'whitelistedDomains' does not exist in type 'JwtConfig'.ts(2322) angular-jwt.module.d.ts(14, 5): The expected type comes from property 'config' which is declared here on type 'JwtModuleOptions'

underlined error occurs at whitelistedDomains

app.module.ts

    imports: [
    BrowserModule,
    NgbModule,
    .
    .
    AppRoutingModule,
    JwtModule.forRoot({
      config:{
        tokenGetter:() => {
          return localStorage.getItem('access_token');

        },
        whitelistedDomains: ['localhost:8080'],
        blacklistedRoutes:[]
      }
    })
       
    ],
Run Code Online (Sandbox Code Playgroud)

Mic*_*l D 12

如果您查看JwtConfig界面,则找不到whitelistedDomainsblacklistedRoutes属性。可能你正在寻找allowedDomainsdisallowedRoutes属性。尝试以下

JwtModule.forRoot({
  config:{
    tokenGetter:() => {
      return localStorage.getItem('access_token');
    },
    allowedDomains: ['localhost:8080'],
    disallowedRoutes:[]
  }
})
Run Code Online (Sandbox Code Playgroud)

  • 如果您在早期版本上查看同一文件,您会发现变量显然已从 WhitelistDomains 重命名为 allowedDomains。请参阅4.2.0:https://github.com/auth0/angular2-jwt/blob/v4.2.0/projects/angular-jwt/src/lib/angular-jwt.module.ts (4认同)