Skip to content

Commit

Permalink
log req
Browse files Browse the repository at this point in the history
  • Loading branch information
DirkSchlossmacher committed Sep 16, 2024
1 parent b5699f6 commit 5c7dc11
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,28 @@ export default withAuth({
callbacks: {
authorized: ({ token }) => {
// Allow access if the token exists
console.log("token", token);
console.log("token.email", token);
return !!token;
},
},
async middleware(req, res, next) {
// Log the request method and URL
console.log(`Request Method: ${req.method}, Request URL: ${req.url}`);

// Log the request payload if it's a POST or PUT request
if (req.method === 'POST' || req.method === 'PUT') {
let body = '';
req.on('data', chunk => {
body += chunk.toString();
});
req.on('end', () => {
console.log('Request Payload:', body);
});
}

// Call the next middleware or route handler
next();
}
});

export const config = {
Expand Down

0 comments on commit 5c7dc11

Please sign in to comment.