Good morning,
I have a rest webservice made with spring boot that works correctly when the token was sent by postman but when sending it from my front it does not work correctly, it showed that the token sent from another application travels this way
GET / xxxxx / yyy / v0 / commercialmanagement / opportunities / 10010999 HTTP / 1.1 Host: conecta.medplus.net.co:7443 Connection: keep-alive Accept: / Authorization : Bearer eyJhbGciOiJIUzI1NiJ9.eyJpZExvZ2luIjoyNDQ1NywiY2xhdmVWZW50YUFzZXNvciI6IjUzMDQiLCJ1c2VyTmFtZSI6IkNvbmVjdGFNZWRwbHVzIiwiY29kU3VjdXJzYWwiOjEsImNvZERlcGFydGFtZW50byI6MTEwMDEsInN1YiI6IlZJQ1RPUiBXSUxMSUFNIExFT04gUklOQ09OIiwiYXVkIjoiWzE1MF0iLCJleHAiOjE1NDUzMzIwNDMsImlhdCI6MTU0NTMxNzY0M30.YrBba-B3byCVbTrnDC9e-kc5bwCNB6tOBw3XV-URzCE User-Agent: Mozilla / 5.0 (Windows NT 10.0; Win64; x64) AppleWebKit / 537.36 (KHTML, like Gecko) Chrome / 71.0.3578.98 Safari / 537.36 Referer: link Accept-Encoding: gzip, deflate, br Accept-Language: en-419, es; q = 0.9, en; q = 0.8
But when sending it from my front it does not leave the authorization field appears in the field of access-control-request-headers
OPTIONS / v1 / inputParameter / country HTTP / 1.1 Host: localhost: 9002 Connection: keep-alive Access-Control-Request-Method: GET Origin: link User-Agent: Mozilla / 5.0 (Windows NT 10.0; Win64; x64) AppleWebKit / 537.36 (KHTML, like Gecko) Chrome / 71.0.3578.98 Safari / 537.36 Access-Control-Request-Headers: authorization, content-type Accept: / Referer: link Accept-Encoding: gzip, deflate, br Accept-Language: en-419, es; q = 0.9, en; q = 0.8
My angular code where I assign the token is the following
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from
'@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { System } from 'src/System';
@Injectable()
export class JwtInterceptor implements HttpInterceptor {
system : System;
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
this.system = new System();
req = req.clone({
setHeaders: {
'Content-Type' : 'application/json; charset=utf-8',
'Accept' : 'application/json',
'Authorization': 'Bearer '+this.system.getToken(),
},
});
return next.handle(req);
}
}