idek man
Some checks failed
CI / Get Changed Files (pull_request) Successful in 6s
CI / prettier (pull_request) Failing after 23s
CI / Checkstyle Main (pull_request) Successful in 44s
CI / test-build (pull_request) Failing after 55s
CI / eslint (pull_request) Failing after 57s

This commit is contained in:
csimonis 2025-03-13 12:28:52 +01:00 committed by Constantin Simonis
commit 242b72ca45
No known key found for this signature in database
GPG key ID: 3878FF77C24AF4D2
7 changed files with 55 additions and 26 deletions

View file

@ -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);
}