-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ffb4ec4
commit 2d79d54
Showing
8 changed files
with
67 additions
and
13 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
src/app/api/firebase-admin-config.ts → src/firebase-admin-config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { NextRequest, NextResponse } from "next/server"; | ||
// import adminAuth from "./firebase-admin-config"; | ||
|
||
export async function middleware(request: NextRequest) { | ||
try { | ||
const authHeader = request.headers.get('Authorization'); | ||
if (!authHeader) { | ||
throw new Error('Authorization header is required'); | ||
} | ||
|
||
const token = authHeader.split('Bearer ')[1]; | ||
if (!token) { | ||
throw new Error('Bearer token is required'); | ||
} | ||
|
||
// const firebaseUser = await adminAuth.verifyIdToken(token); | ||
// console.log(firebaseUser); | ||
// if (!firebaseUser) { | ||
// return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); | ||
// } | ||
|
||
// Check if uid in database or special user | ||
|
||
return NextResponse.next(); | ||
} catch (error) { | ||
return NextResponse.json({ error: (error as Error).message }, { status: 400 }); | ||
} | ||
} | ||
|
||
export const config = { | ||
matcher: ['/api/models', '/api/models/copy', '/api/models/create', '/api/models/pull', '/api/users/:path', '/api/embed'], | ||
}; |