This commit is contained in:
Darren Clarke 2023-07-18 12:26:57 +00:00
parent 7ca5f2d45a
commit f901f203b0
302 changed files with 9897 additions and 10332 deletions

View file

@ -21,7 +21,7 @@ const rewriteURL = (request: NextRequestWithAuth, originBaseURL: string, destina
requestHeaders.delete('connection');
console.log({ finalHeaders: requestHeaders });
// console.log({ finalHeaders: requestHeaders });
return NextResponse.rewrite(new URL(destinationURL), { request: { headers: requestHeaders } });
};
@ -31,8 +31,10 @@ 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 leafcutterURL = process.env.LEAFCUTTER_URL ?? "http://leafcutter:3000";
const metamigoURL = process.env.METAMIGO_URL ?? "http://metamigo:3000";
const leafcutterURL = process.env.LEAFCUTTER_URL ?? "https://lc.digiresilience.org";
const metamigoURL = process.env.METAMIGO_URL ?? "http://metamigo-frontend:3000";
console.log({ linkBaseURL, zammadURL, leafcutterURL, metamigoURL });
if (request.nextUrl.pathname.startsWith('/proxy/leafcutter')) {
const headers = { 'X-Leafcutter-Embedded': "true" };
@ -43,14 +45,14 @@ const checkRewrites = async (request: NextRequestWithAuth) => {
console.log('proxying to zammad');
const { token } = request.nextauth;
console.log({ nextauth: request.nextauth });
// console.log({ nextauth: request.nextauth });
const headers = {
'X-Forwarded-User': token.email.toLowerCase(),
host: 'link-stack-dev.digiresilience.org'
};
console.log({ headers });
// console.log({ headers });
return rewriteURL(request, `${linkBaseURL}/proxy/zammad`, zammadURL, headers);
} else if (request.nextUrl.pathname.startsWith('/assets') || request.nextUrl.pathname.startsWith('/api/v1')) {