Skip to content

Commit eaa98c9

Browse files
committed
fix: Add CORS support for Codespaces and restore MantineProvider
Backend changes: - Updated CORS middleware to use allow_origin_regex pattern - Allows all *.app.github.dev origins (Codespaces) - Maintains localhost support for local development Frontend changes: - Restored MantineProvider wrapper in App.tsx - Fixes crashes in PolicyList and PolicyViolations components - Both shadcn/ui and Mantine components now work together This resolves: - CORS policy blocking API calls from Codespace frontend - React crashes when rendering pages with Mantine components
1 parent 7aaa764 commit eaa98c9

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

AIGovHub/backend/app/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ async def lifespan(app: FastAPI):
2222
lifespan=lifespan
2323
)
2424

25+
import re
26+
2527
app.add_middleware(
2628
CORSMiddleware,
27-
allow_origins=["http://localhost:5173", "http://localhost:3000"],
29+
allow_origin_regex=r"https://.*\.app\.github\.dev|http://localhost:.*",
2830
allow_credentials=True,
2931
allow_methods=["*"],
3032
allow_headers=["*"],

AIGovHub/frontend/src/App.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { BrowserRouter, Routes, Route } from "react-router-dom";
2+
import { MantineProvider } from "@mantine/core";
23
import { ModelList } from "./components/ModelList";
34
import { ModelForm } from "./components/ModelForm";
45
import { ModelDetail } from "./components/ModelDetail";
@@ -9,18 +10,20 @@ import { AppShell } from "./components/layout/AppShell";
910

1011
function App() {
1112
return (
12-
<BrowserRouter>
13-
<AppShell>
14-
<Routes>
15-
<Route path="/" element={<ModelList />} />
16-
<Route path="/dashboard" element={<ComplianceDashboard />} />
17-
<Route path="/policies" element={<PolicyList />} />
18-
<Route path="/violations" element={<PolicyViolations />} />
19-
<Route path="/new" element={<ModelForm />} />
20-
<Route path="/models/:id" element={<ModelDetail />} />
21-
</Routes>
22-
</AppShell>
23-
</BrowserRouter>
13+
<MantineProvider>
14+
<BrowserRouter>
15+
<AppShell>
16+
<Routes>
17+
<Route path="/" element={<ModelList />} />
18+
<Route path="/dashboard" element={<ComplianceDashboard />} />
19+
<Route path="/policies" element={<PolicyList />} />
20+
<Route path="/violations" element={<PolicyViolations />} />
21+
<Route path="/new" element={<ModelForm />} />
22+
<Route path="/models/:id" element={<ModelDetail />} />
23+
</Routes>
24+
</AppShell>
25+
</BrowserRouter>
26+
</MantineProvider>
2427
);
2528
}
2629

0 commit comments

Comments
 (0)