Spaces:
Sleeping
Sleeping
Commit ·
db8667c
1
Parent(s): fa66bf2
apply changes
Browse files- src/middleware.ts +3 -1
src/middleware.ts
CHANGED
|
@@ -8,6 +8,7 @@ const allowedOrigins = [
|
|
| 8 |
"http://localhost:3000", // Next.js dev
|
| 9 |
"https://open-triage.vercel.app",
|
| 10 |
"https://opentriage.onrender.com",
|
|
|
|
| 11 |
];
|
| 12 |
|
| 13 |
// JWT Secret for token verification
|
|
@@ -40,7 +41,8 @@ function verifyToken(token: string): { user_id: string; role: string | null } |
|
|
| 40 |
|
| 41 |
export function middleware(request: NextRequest) {
|
| 42 |
const origin = request.headers.get("origin") || "";
|
| 43 |
-
|
|
|
|
| 44 |
const pathname = request.nextUrl.pathname;
|
| 45 |
|
| 46 |
// Handle preflight requests
|
|
|
|
| 8 |
"http://localhost:3000", // Next.js dev
|
| 9 |
"https://open-triage.vercel.app",
|
| 10 |
"https://opentriage.onrender.com",
|
| 11 |
+
"https://open-triage-6r2y.vercel.app", // Specific preview deployment
|
| 12 |
];
|
| 13 |
|
| 14 |
// JWT Secret for token verification
|
|
|
|
| 41 |
|
| 42 |
export function middleware(request: NextRequest) {
|
| 43 |
const origin = request.headers.get("origin") || "";
|
| 44 |
+
// Allow any Vercel preview deployment or listed origins
|
| 45 |
+
const isAllowedOrigin = allowedOrigins.includes(origin) || origin.endsWith(".vercel.app");
|
| 46 |
const pathname = request.nextUrl.pathname;
|
| 47 |
|
| 48 |
// Handle preflight requests
|