Changes from live
This commit is contained in:
parent
d2522521dd
commit
d0f9e8bb65
11 changed files with 22076 additions and 22031 deletions
|
|
@ -18,6 +18,7 @@ COPY --from=builder ${APP_DIR}/out/package-lock.json ./package-lock.json
|
|||
RUN npm ci --omit=dev
|
||||
|
||||
COPY --from=builder ${APP_DIR}/out/full/ .
|
||||
ARG LINK_EMBEDDED=true
|
||||
RUN npm i -g turbo
|
||||
RUN turbo run build --filter=leafcutter
|
||||
|
||||
|
|
|
|||
|
|
@ -13,11 +13,13 @@ export const Layout: FC<PropsWithChildren> = ({ children }) => {
|
|||
const [cookies, setCookie] = useCookies(["cookieConsent"]);
|
||||
|
||||
const consentGranted = cookies.cookieConsent === "true";
|
||||
|
||||
/*
|
||||
const {
|
||||
publicRuntimeConfig: { embedded },
|
||||
} = getConfig();
|
||||
*/
|
||||
|
||||
const embedded = true;
|
||||
const {
|
||||
colors: {
|
||||
white,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
module.exports = {
|
||||
publicRuntimeConfig: {
|
||||
embedded: Boolean(process.env.LINK_EMBEDDED),
|
||||
embedded: true
|
||||
},
|
||||
basePath: "/proxy/leafcutter",
|
||||
assetPrefix: "/proxy/leafcutter",
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ COPY --from=builder ${APP_DIR}/out/package-lock.json ./package-lock.json
|
|||
RUN npm ci --omit=dev
|
||||
|
||||
COPY --from=builder ${APP_DIR}/out/full/ .
|
||||
ARG LINK_URL=https://link-stack-dev.digiresilience.org
|
||||
RUN npm i -g turbo
|
||||
RUN turbo run build --filter=link
|
||||
|
||||
|
|
|
|||
|
|
@ -335,13 +335,13 @@ export const Sidebar: FC<SidebarProps> = ({ open, setOpen }) => {
|
|||
/>
|
||||
<MenuItem
|
||||
name="Tickets"
|
||||
href="/tickets/assigned"
|
||||
href="/tickets/3"
|
||||
Icon={FeaturedPlayListIcon}
|
||||
selected={pathname.startsWith("/tickets")}
|
||||
iconSize={20}
|
||||
open={open}
|
||||
/>
|
||||
|
||||
{/*
|
||||
<Collapse
|
||||
in={pathname.startsWith("/tickets")}
|
||||
timeout="auto"
|
||||
|
|
@ -387,15 +387,15 @@ export const Sidebar: FC<SidebarProps> = ({ open, setOpen }) => {
|
|||
/>
|
||||
<MenuItem
|
||||
name="New Ticket UI"
|
||||
href="/tickets/2"
|
||||
href="/tickets/3"
|
||||
Icon={SettingsIcon}
|
||||
iconSize={0}
|
||||
selected={pathname.endsWith("/tickets/2")}
|
||||
selected={pathname.endsWith("/tickets/3")}
|
||||
open={open}
|
||||
/>
|
||||
</List>
|
||||
</Collapse>
|
||||
|
||||
*/ }
|
||||
<MenuItem
|
||||
name="Knowledge Base"
|
||||
href="/knowledge"
|
||||
|
|
@ -406,7 +406,7 @@ export const Sidebar: FC<SidebarProps> = ({ open, setOpen }) => {
|
|||
/>
|
||||
<MenuItem
|
||||
name="Leafcutter"
|
||||
href="/leafcutter"
|
||||
href="/leafcutter/about"
|
||||
Icon={AnalyticsIcon}
|
||||
iconSize={20}
|
||||
selected={pathname.endsWith("/leafcutter")}
|
||||
|
|
@ -419,6 +419,7 @@ export const Sidebar: FC<SidebarProps> = ({ open, setOpen }) => {
|
|||
onClick={undefined}
|
||||
>
|
||||
<List component="div" disablePadding>
|
||||
{/*
|
||||
<MenuItem
|
||||
name="Dashboard"
|
||||
href="/leafcutter"
|
||||
|
|
@ -442,7 +443,7 @@ export const Sidebar: FC<SidebarProps> = ({ open, setOpen }) => {
|
|||
selected={pathname.endsWith("/leafcutter/trends")}
|
||||
open={open}
|
||||
/>
|
||||
|
||||
*/}
|
||||
<MenuItem
|
||||
name="FAQ"
|
||||
href="/leafcutter/faq"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { NextResponse } from 'next/server';
|
||||
import type { NextRequest } from 'next/server';
|
||||
import { withAuth } from "next-auth/middleware";
|
||||
import { getToken } from "next-auth/jwt";
|
||||
import { withAuth, NextRequestWithAuth } from "next-auth/middleware";
|
||||
|
||||
const rewriteURL = (request: NextRequest, originBaseURL: string, destinationBaseURL: string, headers: any = {}) => {
|
||||
if (request.nextUrl.pathname.includes('/_next/static/development/')) {
|
||||
|
|
@ -11,31 +10,51 @@ const rewriteURL = (request: NextRequest, originBaseURL: string, destinationBase
|
|||
const destinationURL = request.url.replace(originBaseURL, destinationBaseURL);
|
||||
console.log(`Rewriting ${request.url} to ${destinationURL}`);
|
||||
|
||||
return NextResponse.rewrite(new URL(destinationURL), { ...request.headers, ...headers });
|
||||
const requestHeaders = new Headers(request.headers);
|
||||
for (const [key, value] of Object.entries(headers)) {
|
||||
// @ts-ignore
|
||||
requestHeaders.set(key, value);
|
||||
}
|
||||
|
||||
requestHeaders.delete('connection');
|
||||
|
||||
console.log({finalHeaders: requestHeaders});
|
||||
|
||||
return NextResponse.rewrite(new URL(destinationURL), { request: { headers: requestHeaders } });
|
||||
};
|
||||
|
||||
const checkRewrites = async (request: NextRequest) => {
|
||||
const checkRewrites = async (request: NextRequestWithAuth) => {
|
||||
console.log({currentURL: request.nextUrl.href});
|
||||
|
||||
const linkBaseURL = "http://localhost:3000";
|
||||
const zammadURL = "http://zammad-nginx:8080";
|
||||
if (request.nextUrl.pathname.startsWith('/proxy/leafcutter')) {
|
||||
return rewriteURL(request, process.env.LINK_URL, process.env.LEAFCUTTER_URL);
|
||||
return rewriteURL(request, linkBaseURL, "http://leafcutter:3000");
|
||||
} else if (request.nextUrl.pathname.startsWith('/proxy/metamigo')) {
|
||||
return rewriteURL(request, process.env.LINK_URL, process.env.METAMIGO_URL);
|
||||
return rewriteURL(request, linkBaseURL, "http://metamigo:3000");
|
||||
} else if (request.nextUrl.pathname.startsWith('/proxy/zammad')) {
|
||||
const session = await getToken({
|
||||
req: request,
|
||||
secret: process.env.NEXTAUTH_SECRET,
|
||||
});
|
||||
console.log('proxying to zammad');
|
||||
const { token } = request.nextauth;
|
||||
|
||||
console.log({nextauth: request.nextauth});
|
||||
|
||||
const headers = {
|
||||
'X-Forwarded-User': session.email.toLowerCase(),
|
||||
host: 'zammad.example.com'
|
||||
'X-Forwarded-User': token.email.toLowerCase(),
|
||||
host: 'link-stack-dev.digiresilience.org'
|
||||
};
|
||||
|
||||
return rewriteURL(request, `${process.env.LINK_URL}/proxy/zammad`, process.env.ZAMMAD_URL, headers);
|
||||
} else if (request.nextUrl.pathname.startsWith('/assets')) {
|
||||
console.log({headers});
|
||||
|
||||
return rewriteURL(request, `${linkBaseURL}/proxy/zammad`, zammadURL, headers);
|
||||
} else if (request.nextUrl.pathname.startsWith('/assets') || request.nextUrl.pathname.startsWith('/api/v1')) {
|
||||
console.log('asset');
|
||||
return rewriteURL(request, `${process.env.LINK_URL}`, process.env.ZAMMAD_URL);
|
||||
} else if (request.nextUrl.pathname.startsWith('/proxy/assets') || request.nextUrl.pathname.startsWith('/proxy/api')) {
|
||||
return rewriteURL(request, linkBaseURL, zammadURL);
|
||||
} else if (request.nextUrl.pathname.startsWith('/proxy/assets')) {
|
||||
console.log('proxy asset');
|
||||
return rewriteURL(request, `${process.env.LINK_URL}/proxy`, process.env.ZAMMAD_URL);
|
||||
return rewriteURL(request, `${linkBaseURL}/proxy`, zammadURL);
|
||||
} else if (request.nextUrl.pathname.startsWith('/proxy/api')) {
|
||||
console.log('proxy api');
|
||||
return rewriteURL(request, `${linkBaseURL}/proxy`, zammadURL);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -71,4 +90,3 @@ export default withAuth(
|
|||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,16 @@ const nextConfig = {
|
|||
leafcutterURL: process.env.LEAFCUTTER_URL,
|
||||
metamigoURL: process.env.METAMIGO_URL,
|
||||
},
|
||||
async rewrites() {
|
||||
return {
|
||||
fallback: [
|
||||
{
|
||||
source: '/:path*',
|
||||
destination: `/proxy/zammad/:path*`,
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = nextConfig;
|
||||
|
|
|
|||
5
apps/link/pages/api/v1/users
Normal file
5
apps/link/pages/api/v1/users
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
|
||||
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
res.redirect(307, '/proxy/zammad/api/v1' + req.url.substring('/api/v1'.length));
|
||||
}
|
||||
|
|
@ -49,7 +49,7 @@ const Login: FC<LoginProps> = ({ session }) => {
|
|||
sx={buttonStyles}
|
||||
onClick={() =>
|
||||
signIn("google", {
|
||||
callbackUrl: `${origin}/auth/sso`,
|
||||
callbackUrl: `${origin}/proxy/zammad/auth/sso`,
|
||||
})
|
||||
}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -227,6 +227,9 @@ services:
|
|||
ZAMMAD_API_TOKEN: ${ZAMMAD_API_TOKEN}
|
||||
ZAMMAD_VIRUAL_HOST: ${ZAMMAD_VIRTUAL_HOST}
|
||||
LINK_URL: ${LINK_URL}
|
||||
LEAFCUTTER_URL: http://leafcutter:3000
|
||||
METAMIGO_URL: http://metamigo-frontend:3000
|
||||
ZAMMAD_URL: http://zammad-nginx:8080
|
||||
NEXTAUTH_URL: ${LINK_URL}
|
||||
NEXTAUTH_SECRET: ${NEXTAUTH_SECRET}
|
||||
NEXTAUTH_AUDIENCE: ${NEXTAUTH_AUDIENCE}
|
||||
|
|
@ -246,6 +249,11 @@ services:
|
|||
- "8004:3000"
|
||||
environment:
|
||||
LINK_EMBEDDED: "true"
|
||||
NEXTAUTH_URL: ${LINK_URL}
|
||||
NEXTAUTH_SECRET: ${NEXTAUTH_SECRET}
|
||||
NEXTAUTH_AUDIENCE: ${NEXTAUTH_AUDIENCE}
|
||||
NEXTAUTH_SIGNING_KEY_B64: ${NEXTAUTH_SIGNING_KEY_B64}
|
||||
NEXTAUTH_ENCRYPTION_KEY_B64: ${NEXTAUTH_ENCRYPTION_KEY_B64}
|
||||
|
||||
volumes:
|
||||
elasticsearch-data:
|
||||
|
|
|
|||
5
package-lock.json
generated
5
package-lock.json
generated
|
|
@ -12,7 +12,7 @@
|
|||
"apps/*",
|
||||
"packages/*"
|
||||
],
|
||||
"dependencies": {
|
||||
"devDependencies": {
|
||||
"prettier": "^2.8.8"
|
||||
}
|
||||
},
|
||||
|
|
@ -85,11 +85,9 @@
|
|||
"@mui/x-date-pickers-pro": "^6.5.0",
|
||||
"date-fns": "^2.30.0",
|
||||
"graphql-request": "^6.1.0",
|
||||
"http-proxy-middleware": "^2.0.6",
|
||||
"material-ui-popup-state": "^5.0.8",
|
||||
"next": "13.4.3",
|
||||
"next-auth": "^4.22.1",
|
||||
"next-http-proxy-middleware": "^1.2.5",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"react-iframe": "^1.8.5",
|
||||
|
|
@ -17300,6 +17298,7 @@
|
|||
"version": "2.8.8",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz",
|
||||
"integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"prettier": "bin-prettier.js"
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue