Merge pull request #152 in TEA/mina-sidor-fa-web from feature/interceptor-ignores to develop
Squashed commit of the following: commit 071f0cf45e90302b32544bfdd0764766f5a324bd Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Tue Sep 28 20:08:22 2021 +0200 Now possible to ignore certain request url inside interceptor commit f909f601e7db0b40c492d6362dccc24c67ccc1ed Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Tue Sep 28 19:51:10 2021 +0200 WIP
This commit is contained in:
@@ -22,6 +22,11 @@ export class AuthInterceptor implements HttpInterceptor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
intercept(req: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
|
intercept(req: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
|
||||||
|
const shouldSkipHeaders = environment.api.skipHeadersOn.some(pattern => req.url.indexOf(pattern) > -1);
|
||||||
|
if (shouldSkipHeaders) {
|
||||||
|
return next.handle(req);
|
||||||
|
}
|
||||||
|
|
||||||
const clonedRequest: HttpRequest<unknown> = req.clone({
|
const clonedRequest: HttpRequest<unknown> = req.clone({
|
||||||
setHeaders: { ...environment.api.headers, ...this.authorizationToken, ...this.selectedOrganizationNumber },
|
setHeaders: { ...environment.api.headers, ...this.authorizationToken, ...this.selectedOrganizationNumber },
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export interface Environment {
|
|||||||
api: {
|
api: {
|
||||||
url: string;
|
url: string;
|
||||||
headers: { [key: string]: string };
|
headers: { [key: string]: string };
|
||||||
|
skipHeadersOn: string[];
|
||||||
};
|
};
|
||||||
activeFeatures: Feature[];
|
activeFeatures: Feature[];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export const environment: Environment = {
|
|||||||
api: {
|
api: {
|
||||||
url: '/api',
|
url: '/api',
|
||||||
headers: {},
|
headers: {},
|
||||||
|
skipHeadersOn: ['assets/'],
|
||||||
},
|
},
|
||||||
activeFeatures: [...ACTIVE_FEATURES_PROD],
|
activeFeatures: [...ACTIVE_FEATURES_PROD],
|
||||||
...CIAM_TEST,
|
...CIAM_TEST,
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export const environment: Environment = {
|
|||||||
api: {
|
api: {
|
||||||
url: '/api',
|
url: '/api',
|
||||||
headers: {},
|
headers: {},
|
||||||
|
skipHeadersOn: ['assets/'],
|
||||||
},
|
},
|
||||||
activeFeatures: [...ACTIVE_FEATURES_TEST],
|
activeFeatures: [...ACTIVE_FEATURES_TEST],
|
||||||
...CIAM_TEST,
|
...CIAM_TEST,
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export const environment: Environment = {
|
|||||||
api: {
|
api: {
|
||||||
url: '/api',
|
url: '/api',
|
||||||
headers: {},
|
headers: {},
|
||||||
|
skipHeadersOn: ['assets/'],
|
||||||
},
|
},
|
||||||
activeFeatures: [...ACTIVE_FEATURES_PROD],
|
activeFeatures: [...ACTIVE_FEATURES_PROD],
|
||||||
...CIAM_PROD,
|
...CIAM_PROD,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export const environment: Environment = {
|
|||||||
api: {
|
api: {
|
||||||
url: '/api',
|
url: '/api',
|
||||||
headers: {},
|
headers: {},
|
||||||
|
skipHeadersOn: [],
|
||||||
},
|
},
|
||||||
activeFeatures: [...ACTIVE_FEATURES_TEST, Feature.MOCK_LOGIN],
|
activeFeatures: [...ACTIVE_FEATURES_TEST, Feature.MOCK_LOGIN],
|
||||||
...CIAM_MOCK,
|
...CIAM_MOCK,
|
||||||
|
|||||||
Reference in New Issue
Block a user