Philip Tran
Error when implementing nuxtauth: [Vue Router warn]:No match found for location with path "/session"
Hi everyone, I've been trying to use nuxtauth sidebase but as soon as I create the [...].ts file in server/api/[...].ts (the actual code inside this file and nuxt config below" . I got the error "WARN [Vue Router warn]: No match found for location with path "/session"". And I can't view the side on the front end.
this is [...].ts
import { NuxtAuthHandler } from "#auth";
import CredentialsProvider from "next-auth/providers/credentials";
export default NuxtAuthHandler({
secret: "quyetsecret",
providers: [
//@ts-expect-error
CredentialsProvider.default({
name: "credentials",
credentials: {},
async authorize(credentials: { email: string; password: string }) {
// fetch user form data base
return {};
},
}),
],
session: {
strategy: "jwt",
},
callbacks: {
async jwt({ token, user, account }) {
if (user) {
token = {
...token,
...user,
};
}
return token;
},
async session({ session, token }) {
session.user = {
...token,
...session.user,
};
return session;
},
},
});
this is nuxtconfig: // https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
compatibilityDate: "2024-11-01",
devtools: { enabled: true },
modules: ["@nuxtjs/tailwindcss", "@sidebase/nuxt-auth", "nuxt-server-utils"],
auth: {
baseURL: process.env.AUTH_ORIGIN || "http://localhost:3000/",
provider: {
type: "authjs",
},
},
});
Thank you!
6 replies