Skip to content

Using getCurrentUser in global auth middle causes No Firebase App error #1388

Closed Answered by johnpuaoi
johnpuaoi asked this question in Questions and Help
Discussion options

You must be logged in to vote

Realized there was an issue with my appcheck config and the import of getCurrentUser, corrected my app check config and changed middleware to below, issue is gone.

export default defineNuxtRouteMiddleware(async (to, from) => {
  const user = await getCurrentUser();

  // IF the user is going to the auth page and there is no auth user, let them go
  if (to.path === '/' && !user) {
    return;
  }

  // If no auth user and not going to auth page, redirect to auth page, with redirect query
  if (!user) {
    return navigateTo({
      path: '/',
      query: {
        redirect: to.fullPath,
        authMode: 'login',
      },
    });
  } else if (user && to.path === '/') {
    return navigateTo(

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by johnpuaoi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant