Skip to content

Commit

Permalink
token log
Browse files Browse the repository at this point in the history
  • Loading branch information
DirkSchlossmacher committed Sep 16, 2024
1 parent fd8628a commit 262389e
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,12 @@

// gpt-o1 middleware.ts

import { NextResponse } from 'next/server';
import { withAuth } from 'next-auth/middleware';
import { withAuth } from "next-auth/middleware";

// Custom middleware to log requests
export function middleware(req) {
console.log(`Request Method: ${req.method}, Request URL: ${req.url}`);

if (req.method === 'POST' || req.method === 'PUT') {
req.clone().json().then(body => {
console.log('Request Payload:', body);
}).catch(() => {
console.log('Failed to parse request payload');
});
}

return NextResponse.next();
}

// Authentication middleware
export default withAuth({
callbacks: {
authorized: ({ token }) => {
console.log("token.email", token?.email);
// Allow access if the token exists
return !!token;
},
},
Expand Down

0 comments on commit 262389e

Please sign in to comment.