Vercel is charging for supabase middleware function (update session), any workaround?
Hi,
90% of my vercel costs are coming from the supabase middleware, how can I fix it?

4 Replies
I believe this is normal, since the middleware is a NextJS/Vercel feature. It does run Supabase auth code, but is not a Supabase functionality.
would it achieve the same funcitonality if instead of middlewere I do it in layout?
I don't think so, since Supabase auth needs to set cookies on your request, this is only supported on middleware or api routes if I'm not mistaken. Better to check the nextjs docs...
do you know how to stop these logs?
AuthApiError: Invalid Refresh Token: Refresh Token Not Found
at dk (.next/server/src/middleware.js:33:29611)
at async dm (.next/server/src/middleware.js:33:30585)
at async dl (.next/server/src/middleware.js:33:29995)
at async c (.next/server/src/middleware.js:33:66145)
at async (.next/server/src/middleware.js:33:66408) {
__isAuthError: true,
status: 400,
code: 'refresh_token_not_found'
I can't seems to be able to catch them, does supabase log them internally?