Whatsapp send and Zammad autologin fixes

This commit is contained in:
Darren Clarke 2023-09-08 16:34:13 +02:00
parent a3d6b786e1
commit 9e68be7225
15 changed files with 153 additions and 100 deletions

View file

@ -22,20 +22,21 @@ const checkRewrites = async (request: NextRequestWithAuth) => {
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(request.nextUrl);
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);
} else if (request.nextUrl.pathname.startsWith('/zammad')) {
return rewriteURL(request, `${linkBaseURL}/zammad`, zammadURL);
return rewriteURL(request, `${linkBaseURL}/zammad`, zammadURL, headers);
} else if (request.nextUrl.pathname.startsWith('/auth/sso') || request.nextUrl.pathname.startsWith('/assets')) {
const headers = { 'X-Forwarded-User': token.email.toLowerCase() };
return rewriteURL(request, linkBaseURL, zammadURL, headers);
} else if (request.nextUrl.pathname.startsWith('/proxy/api') || request.nextUrl.pathname.startsWith('/proxy/assets')) {
return rewriteURL(request, `${linkBaseURL}/proxy`, zammadURL);
} else if (request.nextUrl.pathname.startsWith('/api/v1') || request.nextUrl.pathname.startsWith('/auth/sso')) {
return rewriteURL(request, linkBaseURL, zammadURL);
return rewriteURL(request, linkBaseURL, zammadURL, headers);
}
return NextResponse.next();
@ -75,7 +76,7 @@ export default withAuth(
export const config = {
matcher: [
'/((?!ws|_next/static|_next/image|favicon.ico).*)',
'/((?!ws|wss|_next/static|_next/image|favicon.ico).*)',
],
};