This commit is contained in:
Darren Clarke 2024-03-16 12:51:56 +01:00
parent c095fa7042
commit 43bfdaa1e3
186 changed files with 276 additions and 37155 deletions

View file

@ -24,12 +24,37 @@ const rewriteURL = (request: NextRequestWithAuth, originBaseURL: string, destina
const checkRewrites = async (request: NextRequestWithAuth) => {
const linkBaseURL = process.env.LINK_URL ?? "http://localhost:3000";
const zammadURL = process.env.ZAMMAD_URL ?? "http://zammad-nginx:8080";
const opensearchURL = process.env.OPENSEARCH_URL ?? "http://macmini:5601";
const metamigoURL = process.env.METAMIGO_URL ?? "http://metamigo-api:3000";
const labelStudioURL = process.env.LABEL_STUDIO_URL ?? "http://label-studio:8080";
const { token } = request.nextauth;
const headers = { 'X-Forwarded-User': token?.email?.toLowerCase() };
console.log ({ pathname: request.nextUrl.pathname});
if (request.nextUrl.pathname.startsWith('/metamigo')) {
if (request.nextUrl.pathname.startsWith('/api/v1/configuration/account') ||
request.nextUrl.pathname.startsWith('/api/v1/restapiinfo') ||
request.nextUrl.pathname.startsWith('/api/v1/auth') ||
request.nextUrl.pathname.startsWith('/api/core') ||
request.nextUrl.pathname.startsWith('/api/dataconnections') ||
request.nextUrl.pathname.startsWith('/api/v1/multitenancy') ||
request.nextUrl.pathname.startsWith('/api/ism') ||
request.nextUrl.pathname.startsWith('/node_modules') ||
request.nextUrl.pathname.startsWith('/translations') || request.nextUrl.pathname.startsWith('/6867') || request.nextUrl.pathname.startsWith('/ui') || request.nextUrl.pathname.startsWith('/bootstrap')) {
const headers = {
'x-proxy-user': "admin",
'x-proxy-roles': "all_access",
// 'X-Forwarded-For': "link"
};
return rewriteURL(request, `${linkBaseURL}`, opensearchURL, headers);
}
else if (request.nextUrl.pathname.startsWith('/opensearch')) {
const headers = {
'x-proxy-user': "admin",
'x-proxy-roles': "all_access",
// 'X-Forwarded-For': "link"
};
return rewriteURL(request, `${linkBaseURL}/opensearch`, opensearchURL, headers);
}else if (request.nextUrl.pathname.startsWith('/metamigo')) {
return rewriteURL(request, `${linkBaseURL}/metamigo`, metamigoURL);
} else if (request.nextUrl.pathname.startsWith('/label-studio')) {
return rewriteURL(request, `${linkBaseURL}/label-studio`, labelStudioURL);
@ -83,4 +108,3 @@ export const config = {
'/((?!ws|wss|_next/static|_next/image|favicon.ico).*)',
],
};