atinux / nuxt-auth-utils

Add Authentication to Nuxt applications with secured & sealed cookies sessions.
MIT License
976 stars 91 forks source link

Does this module work in an SPA setting? #92

Closed ymansurozer closed 6 months ago

ymansurozer commented 6 months ago

I've already seen https://github.com/Atinux/nuxt-auth-utils/issues/9 but wanted to confirm because the requirements highlight:

You cannot use this module with nuxt generate.

Does this mean we can use this module in a Nuxt project where the landing page runs with SSR but the logged in pages are an SPA? Or does it mean the whole auth flow must happen within an SSR context?

I've tried to migrate to this module in my SaaS starter template but it seems it cannot find the user session if I redirect to an SPA page after log in, although if I refresh the page, it returns the session fine.

amandesai01 commented 6 months ago

You will have to keep it SSR. Reason: It uses client secret to fetch creds, which would then be exposed to client side. Not a good practice.

https://github.com/bitinflow/nuxt-oauth Use this to go full SPA.

Feel free to close this issue if this resolves your concern.

ymansurozer commented 6 months ago

Oh I see, thank you very much for clarifying this and also the recommendation. Much appreciated @amandesai01!