Rewrite Zammad API calls in config rather than middleware
This commit is contained in:
parent
f0e8e20c24
commit
781f8c380a
3 changed files with 17 additions and 5 deletions
|
|
@ -18,6 +18,7 @@ RUN npm ci
|
||||||
|
|
||||||
COPY --from=builder ${APP_DIR}/out/full/ .
|
COPY --from=builder ${APP_DIR}/out/full/ .
|
||||||
RUN npm i -g turbo
|
RUN npm i -g turbo
|
||||||
|
ENV ZAMMAD_URL=http://zammad-nginx:8080
|
||||||
RUN turbo run build --filter=@link-stack/link --filter=@link-stack/bridge-migrations
|
RUN turbo run build --filter=@link-stack/link --filter=@link-stack/bridge-migrations
|
||||||
|
|
||||||
FROM base AS runner
|
FROM base AS runner
|
||||||
|
|
|
||||||
|
|
@ -70,9 +70,6 @@ export default withAuth(checkRewrites, {
|
||||||
callbacks: {
|
callbacks: {
|
||||||
authorized: ({ token, req }) => {
|
authorized: ({ token, req }) => {
|
||||||
const path = req.nextUrl.pathname;
|
const path = req.nextUrl.pathname;
|
||||||
if (path.startsWith("/api/v1/")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.env.SETUP_MODE === "true") {
|
if (process.env.SETUP_MODE === "true") {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -95,6 +92,6 @@ export default withAuth(checkRewrites, {
|
||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
matcher: [
|
matcher: [
|
||||||
"/((?!ws|wss|api/signal|api/whatsapp|api/facebook|_next/static|_next/image|favicon.ico).*)",
|
"/((?!ws|wss|api/v1|api/signal|api/whatsapp|api/facebook|_next/static|_next/image|favicon.ico).*)",
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ const nextConfig = {
|
||||||
"@link-stack/ui",
|
"@link-stack/ui",
|
||||||
"@link-stack/bridge-common",
|
"@link-stack/bridge-common",
|
||||||
"@link-stack/bridge-ui",
|
"@link-stack/bridge-ui",
|
||||||
"mui-chips-input"
|
"mui-chips-input",
|
||||||
],
|
],
|
||||||
publicRuntimeConfig: {
|
publicRuntimeConfig: {
|
||||||
linkURL: process.env.LINK_URL ?? "http://localhost:3000",
|
linkURL: process.env.LINK_URL ?? "http://localhost:3000",
|
||||||
|
|
@ -14,6 +14,20 @@ const nextConfig = {
|
||||||
labelStudioURL: process.env.LABEL_STUDIO_URL ?? "http://localhost:8006",
|
labelStudioURL: process.env.LABEL_STUDIO_URL ?? "http://localhost:8006",
|
||||||
muiLicenseKey: process.env.MUI_LICENSE_KEY ?? "",
|
muiLicenseKey: process.env.MUI_LICENSE_KEY ?? "",
|
||||||
},
|
},
|
||||||
|
rewrites: async () => {
|
||||||
|
return {
|
||||||
|
beforeFiles: [
|
||||||
|
{
|
||||||
|
source: "/api/v1/:path*",
|
||||||
|
destination: `${process.env.ZAMMAD_URL}/api/v1/:path*`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
source: "/ws",
|
||||||
|
destination: `${process.env.ZAMMAD_URL}/ws`,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default nextConfig;
|
export default nextConfig;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue