Next.js Discord

Discord Forum

Unable to use postgres in middleware

Unanswered
Cape lion posted this in #help-forum
Open in Discord
Cape lionOP
See title, not much else to report apart from it doesn't work due to various limitations on the edge runtime. Is there a workaround?

7 Replies

Cape lionOP
For reference, we host our own postgres and don't want to use a different host like Vercel Database
Why are you trying to run pg in your middleware is my first question @Cape lion
@Arinji Why are you trying to run pg in your middleware is my first question <@843135686173392946>
Cape lionOP
Need to validate/renew sessions in cookies
Make an api route, and call that from your middleware
Cape lionOP
🥲 then i'll have to make that protected somehow too, i guess
Cape lionOP
Ooh, didn't know that, I'll look into it and mark as a solution if it fits my needs 🙂