authjs-nuxt icon indicating copy to clipboard operation
authjs-nuxt copied to clipboard

WARN [Vue Router warn]: No match found for location with path "/api/auth/session"

Open perspolise opened this issue 7 months ago • 8 comments

I see this warning in console WARN [Vue Router warn]: No match found for location with path "/api/auth/session" and nuxt-auth doesn't work.

[...].ts

import GithubProvider from "@auth/core/providers/github"
import type { AuthConfig } from "@auth/core/types"
import { NuxtAuthHandler } from "#auth"

// The #auth virtual import comes from this module. You can use it on the client
// and server side, however not every export is universal. For example do not
// use sign-in and sign-out on the server side.

const runtimeConfig = useRuntimeConfig()

// Refer to Auth.js docs for more details
export const authOptions: AuthConfig = {
    secret: runtimeConfig.authJs.secret,
    providers: [
        GithubProvider({
            clientId: runtimeConfig.github.clientId,
            clientSecret: runtimeConfig.github.clientSecret
        })
    ]
}

export default NuxtAuthHandler(authOptions, runtimeConfig)

and nuxt.config.ts

export default defineNuxtConfig({
  devtools: { enabled: true },
  modules: ["@hebilicious/authjs-nuxt"],
  authJs: {
    guestRedirectTo: "/redirected"
  },
  nitro: {
    routeRules: {
      "/": { ssr: true, prerender: true },
      "/private": { ssr: true, prerender: true }
    }
  },
  devtools: {
    enabled: true
  },
  experimental: {
    renderJsonPayloads: true
  },
  runtimeConfig: {
    authJs: { secret: "/OEjlRC2DK74ZEj5nl8qHNy+E6/JptnouIyHnANbBz0=" },
    github: {
      clientId: "",
      clientSecret: ""
    },
    public: {
      authJs: {
        baseUrl: "http://localhost:3000",
        verifyClientOnEveryRequest: true
      }
    }
  }
})

dependencies:

  "dependencies": {
    "@auth/core": "^0.34.1",
    "@hebilicious/authjs-nuxt": "^0.3.5",
    "nuxt": "^3.12.2",
    "vue": "latest"
  }

perspolise avatar Jun 29 '24 11:06 perspolise