不能使用auth0 / angular-jwt包含/发送jwt令牌

问题描述 投票:0回答:1

我使用“https://github.com/auth0/angular2-jwt”将JWT令牌发送到我的服务器,我可以在调试http请求(角度)时看到令牌但在服务器(java)上找不到令牌

这是我的配置jwt

JwtModule.forRoot({
  config: {
    headerName: 'API_TOKEN',
    tokenGetter: function tokenGetter() {
      return localStorage.getItem('API_TOKEN');
    },
    whitelistedDomains: ['localhost:8092'],
    // blacklistedRoutes: ['https://localhost:8092/login'],
    authScheme: ''
  }
}),

我添加了一个JwtHttpInterceptor来调试我的请求:

@Injectable()
export class JwtHttpInterceptor implements HttpInterceptor {
  constructor() {}
  intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
 return next.handle(req);
}
}

这是一个截图:JWT token in header request

但服务器找不到此令牌。

当我尝试使用chrome插件添加令牌时,它工作,服务器可以找到我的令牌:qazxsw poi

你能帮我吗?

spring angular7 angular2-jwt
1个回答
0
投票

我找到了解决方案,如果它会帮助另一个人,事实上它来自后端,我扭转了弹簧安全过滤器,我的请求“选项”应该首先通过过滤器CORS

token added with chrome pluging 
© www.soinside.com 2019 - 2024. All rights reserved.