i'm working on nextJS middleware, but i've seen the documentation, stating that the middleware can rewrite routes and affect headers, but it doesn't get the response from the api call. so this code will not be able to log the duration of the call:
const { NextResponse } = require("next/server")
export default function middleware(request){
const startTime = Date.now();
const response = NextResponse.next();
const endTime = Date.now();
const duration = endTime - startTime;
console.log(duration);
return response
}
is there a way to log the function all duration without wrapping every api call in another function or duplicate the call in every function to log the start and end time of API call run?