SUPPORT-9084:fix
This commit is contained in:
parent
bf3404c551
commit
5fe263ed72
2 changed files with 3 additions and 59 deletions
|
|
@ -1,14 +1,14 @@
|
||||||
import {HTTP_INTERCEPTORS} from "@angular/common/http";
|
import {HTTP_INTERCEPTORS} from "@angular/common/http";
|
||||||
import {
|
import {
|
||||||
FormDirtyInterceptor,
|
FormDirtyInterceptor,
|
||||||
HttpSecurityErrorInterceptor
|
HttpSecurityErrorInterceptor,
|
||||||
|
HttpSecurityInterceptor
|
||||||
} from "@webbpm/base-package";
|
} from "@webbpm/base-package";
|
||||||
import {MfeHttpBackendInterceptor} from "./mfe-http-backend-interceptor";
|
|
||||||
import {TokenInterceptor} from "../../app/interceptor/token.interceptor.service";
|
import {TokenInterceptor} from "../../app/interceptor/token.interceptor.service";
|
||||||
|
|
||||||
|
|
||||||
export const DEFAULT_HTTP_INTERCEPTOR_PROVIDERS = [
|
export const DEFAULT_HTTP_INTERCEPTOR_PROVIDERS = [
|
||||||
{provide: HTTP_INTERCEPTORS, useClass: MfeHttpBackendInterceptor, multi: true},
|
{provide: HTTP_INTERCEPTORS, useClass: HttpSecurityInterceptor, multi: true},
|
||||||
{provide: HTTP_INTERCEPTORS, useClass: HttpSecurityErrorInterceptor, multi: true},
|
{provide: HTTP_INTERCEPTORS, useClass: HttpSecurityErrorInterceptor, multi: true},
|
||||||
{provide: HTTP_INTERCEPTORS, useClass: FormDirtyInterceptor, multi: true},
|
{provide: HTTP_INTERCEPTORS, useClass: FormDirtyInterceptor, multi: true},
|
||||||
{provide: HTTP_INTERCEPTORS, useClass: TokenInterceptor, multi: true}
|
{provide: HTTP_INTERCEPTORS, useClass: TokenInterceptor, multi: true}
|
||||||
|
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
||||||
import {HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from "@angular/common/http";
|
|
||||||
import {
|
|
||||||
AppConfigService,
|
|
||||||
ApplicationSettingsProvider,
|
|
||||||
AppVersionService,
|
|
||||||
TokenHeaderUtil
|
|
||||||
} from "@webbpm/base-package";
|
|
||||||
import {Observable} from "rxjs";
|
|
||||||
|
|
||||||
export class MfeHttpBackendInterceptor implements HttpInterceptor {
|
|
||||||
private static readonly CONTENT_TYPE_HEADER = 'Content-Type';
|
|
||||||
private static readonly ENABLE_VERSION_IN_URL: string = "enable.version.in.url";
|
|
||||||
private static readonly BACKEND_URL: string = "backend.url";
|
|
||||||
private static readonly BACKEND_CONTEXT: string = "backend.context";
|
|
||||||
|
|
||||||
constructor(private appConfigService: AppConfigService,
|
|
||||||
private appVersionService: AppVersionService) {
|
|
||||||
}
|
|
||||||
|
|
||||||
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
|
||||||
req = TokenHeaderUtil.addHeader(
|
|
||||||
req, MfeHttpBackendInterceptor.CONTENT_TYPE_HEADER, 'application/json;charset=UTF-8'
|
|
||||||
);
|
|
||||||
|
|
||||||
let overrideObj
|
|
||||||
|
|
||||||
if (!req.url.startsWith(ApplicationSettingsProvider.RESOURCES_PATH)
|
|
||||||
&& !req.url.startsWith('http:') && !req.url.startsWith('https:')) {
|
|
||||||
|
|
||||||
let appVersionInUrl = this.getVersion();
|
|
||||||
let backendUrl = this.appConfigService.getParamValue(MfeHttpBackendInterceptor.BACKEND_URL);
|
|
||||||
let backendContext = this.appConfigService.getParamValue(
|
|
||||||
MfeHttpBackendInterceptor.BACKEND_CONTEXT);
|
|
||||||
|
|
||||||
let url;
|
|
||||||
|
|
||||||
if (backendUrl) {
|
|
||||||
url = backendUrl;
|
|
||||||
}
|
|
||||||
else if (backendContext) {
|
|
||||||
url = backendContext;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
url = ApplicationSettingsProvider.BACKEND_URL;
|
|
||||||
}
|
|
||||||
|
|
||||||
overrideObj = {url: `${url}${appVersionInUrl}/${req.url}`};
|
|
||||||
}
|
|
||||||
return next.handle(req.clone(overrideObj));
|
|
||||||
}
|
|
||||||
|
|
||||||
private getVersion(): string {
|
|
||||||
return this.appConfigService.getParamValue(MfeHttpBackendInterceptor.ENABLE_VERSION_IN_URL) ==
|
|
||||||
"true" ? "-" + this.appVersionService.getAppVersion() : "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue