nuxt-alt / auth

An alternative module to @nuxtjs/auth
https://nuxt-alt-auth.vercel.app/
MIT License
94 stars 20 forks source link

Question: how to protect a server route #65

Closed VladBrok closed 7 months ago

VladBrok commented 10 months ago

Hello. Could you please tell how can I protect the api route. I've tried to use /server/middleware/auth.ts with defineEventHandler and useAuth, but it's not working

Denoder commented 10 months ago

I don't believe there is a way to access the nitro/h3 layer currently. Not sure why nuxt has a nitro server level, a nuxt server level and a nuxt client level. but i'm not looking to rewrite a chunk of the module to accommodate the nitro layer. If I find a simple way to do it ill add it.

You're free to make a PR to accommodate this.

VladBrok commented 10 months ago

@Denoder ok, thank you very much for the quick reply