Skip to content

Commit bcc3085

Browse files
committed
fix: remove admin from sidebar + add PATCH to CORS allowed methods
Two hotfixes: 1. Admin link removed from Sidebar -- was visible to ALL users. Admin page still accessible via /dashboard/admin URL only. Non-admins get 403 from backend, clean error in frontend. 2. PATCH added to CORS allow_methods. The admin tier endpoint uses PATCH but it was missing from the CORS config, causing preflight failures on the tier update call. 3. Added retry:false to AdminPage React Query so non-admin users don't hammer the 403 endpoint.
1 parent a604655 commit bcc3085

3 files changed

Lines changed: 2 additions & 3 deletions

File tree

backend/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ async def dispatch(self, request: Request, call_next):
8484
allow_origins=ALLOWED_ORIGINS,
8585
allow_origin_regex=ALLOW_ORIGIN_REGEX or None,
8686
allow_credentials=True,
87-
allow_methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"],
87+
allow_methods=["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
8888
allow_headers=["Authorization", "Content-Type"],
8989
)
9090

frontend/src/components/dashboard/Sidebar.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Link, useLocation } from 'react-router-dom'
22
import {
33
FolderGit2,
44
BookOpen,
5-
Shield,
65
ChevronLeft,
76
ChevronRight,
87
ExternalLink,
@@ -25,7 +24,6 @@ interface NavItem {
2524

2625
const mainNavItems: NavItem[] = [
2726
{ name: 'Repositories', href: '/dashboard', icon: <FolderGit2 className="w-5 h-5" /> },
28-
{ name: 'Admin', href: '/dashboard/admin', icon: <Shield className="w-5 h-5" /> },
2927
]
3028

3129
const bottomNavItems: NavItem[] = [

frontend/src/pages/AdminPage.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export function AdminPage() {
5050
return resp.json()
5151
},
5252
enabled: !!session?.access_token,
53+
retry: false,
5354
})
5455

5556
const users = data?.users ?? []

0 commit comments

Comments
 (0)