Proxy and env var updates

This commit is contained in:
Darren Clarke 2023-02-06 08:59:53 +00:00
parent 76c80cde8c
commit 86c616de0a
6 changed files with 209 additions and 209 deletions

View file

@ -2,10 +2,13 @@ import { createProxyMiddleware } from "http-proxy-middleware";
import { NextApiRequest, NextApiResponse } from "next";
const proxy = createProxyMiddleware({
target: "https://help.cdr.link",
target: process.env.ZAMMAD_URL,
changeOrigin: true,
xfwd: false,
pathRewrite: { '^/zammad': '' }
pathRewrite: { '^/zammad': '' },
onProxyReq: (proxyReq, req: NextApiRequest) => {
proxyReq.setHeader('X-Forwarded-User', "");
}
});
export default proxy;

View file

@ -27,8 +27,8 @@ export const getServerSideProps: GetServerSideProps = async (
const {
params: { id },
} = context;
const baseURL = "https://help.cdr.link/api/v1";
const token = process.env.ZAMMAD_TOKEN;
const baseURL = `${process.env.ZAMMAD_URL}/api/v1`;
const token = process.env.ZAMMAD_API_TOKEN;
const headers = { Authorization: `Token ${token}` };
const rawTicket = await fetch(`${baseURL}/tickets/${id}`, {
headers,