fumeapp/laranuxt

nuxt v3 - auth module/plugin middleware

acidjazz opened this issue · 4 comments

move loggedIn to a cookie check and stop there - properly respond to an access denied endpoint with removing the session and redirecting properly - keep the FE simple!

@acidjazz has this been done now?

@dammy001 yes - i've actually found that by going after my API calls that require auth, any that respond with a 401 I use to redirect

Just remember to be careful when you do your calls so that when it does 401, you get no js errors so the redirect fires, example:

const { $api } = useNuxtApp()
const teams = ref<models.Teams|undefined>(undefined)
const get = async () => teams.value = (await $api.index<models.Teams>('/team'))?.data
get()

(notice the ?.data)

@dammy001 i talk about this a bit more here

Nice 👍