idek man
Some checks failed
Some checks failed
This commit is contained in:
parent
e848b548b5
commit
242b72ca45
7 changed files with 55 additions and 26 deletions
|
@ -1,8 +1,18 @@
|
|||
import { HttpInterceptorFn } from '@angular/common/http';
|
||||
import { inject } from '@angular/core';
|
||||
import { OAuthStorage } from 'angular-oauth2-oidc';
|
||||
|
||||
export const httpInterceptor: HttpInterceptorFn = (req, next) => {
|
||||
if (localStorage.getItem('jwt')) {
|
||||
return next(req.clone({ setHeaders: { 'Authorization': 'Bearer ' + localStorage.getItem('jwt') } }));
|
||||
const oauthStorage = inject(OAuthStorage);
|
||||
|
||||
if (oauthStorage.getItem('jwt')) {
|
||||
return next(req.clone({
|
||||
setHeaders: {
|
||||
'Authorization': 'Bearer ' + oauthStorage.getItem('jwt'),
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
'Referrer-Policy': 'no-referrer',
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
return next(req);
|
||||
}
|
||||
|
|
Reference in a new issue