Link ticket fixes #1
This commit is contained in:
parent
1443a61164
commit
d9ce2f5883
21 changed files with 617 additions and 583 deletions
|
|
@ -2,6 +2,11 @@ import { NextResponse } from 'next/server';
|
|||
import { withAuth, NextRequestWithAuth } from "next-auth/middleware";
|
||||
|
||||
const rewriteURL = (request: NextRequestWithAuth, originBaseURL: string, destinationBaseURL: string, headers: any = {}) => {
|
||||
if (request.nextUrl.pathname.startsWith('/api/v1/reports/sets')) {
|
||||
console.log(request.nextUrl.searchParams.get("sheet"));
|
||||
NextResponse.next();
|
||||
}
|
||||
|
||||
const destinationURL = request.url.replace(originBaseURL, destinationBaseURL);
|
||||
|
||||
console.log(`Rewriting ${request.url} to ${destinationURL}`);
|
||||
|
|
@ -35,6 +40,7 @@ const checkRewrites = async (request: NextRequestWithAuth) => {
|
|||
} 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') || request.nextUrl.pathname.startsWith('/mobile')) {
|
||||
console.log("THIS PATH");
|
||||
return rewriteURL(request, linkBaseURL, zammadURL, headers);
|
||||
}
|
||||
|
||||
|
|
@ -56,8 +62,9 @@ export default withAuth(
|
|||
const noAuthPaths = ["/login", "/api/v1"];
|
||||
const parsedURL = new URL(url);
|
||||
const path = parsedURL.pathname;
|
||||
console.log({ p: parsedURL.pathname });
|
||||
|
||||
if (noAuthPaths.some((p: string) => path.startsWith(p))) {
|
||||
console.log({ p: parsedURL.pathname, auth: "no" });
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue