debug
This commit is contained in:
@@ -19,10 +19,15 @@ export class AuthInterceptor implements HttpInterceptor {
|
||||
) { }
|
||||
|
||||
intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
|
||||
console.log('Welcome to interceptor:', request.url);
|
||||
console.log('IsAuth?', request.url.includes('/auth/apiToken'));
|
||||
if (!request.url.includes('/auth/apiToken')) {
|
||||
console.log(this.auth$.expirationTime.format(), moment.utc().format());
|
||||
if (this.auth$.expirationTime.isBefore(moment.utc())) {
|
||||
console.log('Need to refresh token');
|
||||
return this.auth$.getAPITokenObservable().pipe(
|
||||
mergeMap(() => {
|
||||
console.log('New token is ready');
|
||||
return next.handle(request.clone({
|
||||
headers: request.headers.set('Authorization', `Bearer ${this.auth$.apiToken}`),
|
||||
}));
|
||||
@@ -38,6 +43,7 @@ export class AuthInterceptor implements HttpInterceptor {
|
||||
})
|
||||
);
|
||||
} else {
|
||||
console.log('TOken is fine');
|
||||
return next.handle(request.clone({
|
||||
headers: request.headers.set('Authorization', `Bearer ${this.auth$.apiToken}`),
|
||||
}));
|
||||
|
||||
@@ -6,8 +6,8 @@ export const environment = {
|
||||
appEnvironment: "local",
|
||||
production: false,
|
||||
api: {
|
||||
url: "http://localhost:5400/api"
|
||||
// url: "https://diunabi.bim-it.pl/api"
|
||||
//url: "http://localhost:5400/api"
|
||||
url: "https://diunabi.bim-it.pl/api"
|
||||
},
|
||||
google: {
|
||||
clientId: "107631825312-bkfe438ehr9k9ecb2h76g802tj6advma.apps.googleusercontent.com"
|
||||
|
||||
Reference in New Issue
Block a user