fix: update Clerk auth to use networkless JWT verification
- Replace deprecated verifySession() with verifyToken() - Use JWT-based authentication (networkless verification) - Update Clerk secret key to correct test key - Fixes 410 Gone error from deprecated endpoint This resolves the authentication issues with file uploads.
This commit is contained in:
@@ -26,10 +26,10 @@ export const requireAuth = async (
|
||||
|
||||
const token = authHeader.substring(7);
|
||||
|
||||
// Verify the session token with Clerk
|
||||
const session = await clerkClient.sessions.verifySession(token, token);
|
||||
// Verify the session token using networkless verification (JWT)
|
||||
const payload = await clerkClient.verifyToken(token);
|
||||
|
||||
if (!session) {
|
||||
if (!payload || !payload.sub) {
|
||||
return res.status(401).json({
|
||||
error: {
|
||||
code: 'INVALID_TOKEN',
|
||||
@@ -39,8 +39,8 @@ export const requireAuth = async (
|
||||
});
|
||||
}
|
||||
|
||||
// Attach user ID to request
|
||||
req.userId = session.userId;
|
||||
// Attach user ID to request (sub is the user ID in JWT)
|
||||
req.userId = payload.sub;
|
||||
|
||||
next();
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user