Skip to content

Commit 812694c

Browse files
committed
Refactor configuration of client software
1 parent 8b76605 commit 812694c

File tree

14 files changed

+99
-34
lines changed

14 files changed

+99
-34
lines changed

client/.env.development

Lines changed: 0 additions & 2 deletions
This file was deleted.

client/.env.production

Lines changed: 0 additions & 2 deletions
This file was deleted.

client/Dockerfile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
ARG NODE_ENV=production
21
FROM node:22-alpine AS build
32

4-
ARG NODE_ENV
5-
ENV NODE_ENV=$NODE_ENV
6-
7-
RUN echo "Building in $NODE_ENV mode"
83
WORKDIR /app
94

105
COPY package*.json ./

client/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"redirectUri": "http://localhost:5173",
3+
"clientId": "60a9e442420a386f2ddff0f60ed0801dd7e826f0710507e982d5afe6aa054334"
4+
}

client/nginx.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ server {
88
try_files $uri /index.html;
99
}
1010

11+
location /config.json {
12+
try_files $uri =404;
13+
add_header Cache-Control "no-cache, no-store, must-revalidate";
14+
add_header Pragma "no-cache";
15+
add_header Expires "0";
16+
}
17+
1118
location /api/ {
1219
proxy_pass http://apigw-service/;
1320
proxy_set_header Host $host;

client/package-lock.json

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
8-
"build": "npx vite build --mode $NODE_ENV",
8+
"build": "npx vite build",
99
"lint": "eslint .",
1010
"preview": "vite preview"
1111
},
@@ -22,6 +22,7 @@
2222
"@types/babel__generator": "^7.6.8",
2323
"@types/babel__template": "^7.4.4",
2424
"@types/babel__traverse": "^7.20.6",
25+
"@types/node": "^24.0.10",
2526
"@types/prop-types": "^15.7.13",
2627
"@types/react": "^18.3.12",
2728
"@types/react-dom": "^18.3.1",

client/src/main.tsx

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,41 @@ import { RouterProvider } from "react-router-dom";
44
import { AuthProvider } from "react-oidc-context";
55
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
66

7-
import { oidcConfig } from "./oidcConfig";
87
import { router } from "./routes/routes";
98
import "./index.css";
109

1110
const queryClient = new QueryClient();
1211

13-
createRoot(document.getElementById("root")!).render(
14-
<StrictMode>
15-
<AuthProvider {...oidcConfig}>
16-
<QueryClientProvider client={queryClient}>
17-
<RouterProvider router={router} />
18-
</QueryClientProvider>
19-
</AuthProvider>
20-
</StrictMode>
21-
);
12+
(async () => {
13+
const gitlabConfig = await fetch("/config.json")
14+
.then((response) => response.json())
15+
.then((config) => config as { redirectUri: string; clientId: string });
16+
17+
const oidcConfig = {
18+
authority: "https://gitlab.lrz.de",
19+
response_type: "code",
20+
scope: "read_user",
21+
onSigninCallback: () => {
22+
const url = new URL(window.location.href);
23+
url.searchParams.delete("code");
24+
url.searchParams.delete("state");
25+
window.history.replaceState(
26+
{},
27+
document.title,
28+
url.pathname + url.search
29+
);
30+
},
31+
redirect_uri: gitlabConfig.redirectUri,
32+
client_id: gitlabConfig.clientId,
33+
};
34+
35+
createRoot(document.getElementById("root")!).render(
36+
<StrictMode>
37+
<AuthProvider {...oidcConfig}>
38+
<QueryClientProvider client={queryClient}>
39+
<RouterProvider router={router} />
40+
</QueryClientProvider>
41+
</AuthProvider>
42+
</StrictMode>
43+
);
44+
})();

client/src/oidcConfig.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

client/vite.config.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
import { defineConfig } from "vite";
22
import react from "@vitejs/plugin-react";
3+
import { readFileSync } from "fs";
34

45
export default defineConfig({
5-
plugins: [react()],
6+
plugins: [
7+
react(),
8+
{
9+
name: "serve-config",
10+
configureServer(server) {
11+
server.middlewares.use("/config.json", (req, res) => {
12+
const config = readFileSync("./config.json", "utf-8");
13+
res.setHeader("Content-Type", "application/json");
14+
res.end(config);
15+
});
16+
},
17+
},
18+
],
619
optimizeDeps: {
720
exclude: ["lucide-react"],
821
},

0 commit comments

Comments
 (0)