Код: Выделить всё
Unknown module type
This module doesn't have an associated type. Use a known file extension, or register a loader for it.
Read more: https://nextjs.org/docs/app/api-reference/next-config-js/turbo#webpack-loaders
Код: Выделить всё
// middleware.js
import { NextResponse } from 'next/server';
import { auth } from './auth';
export function middleware(request) {
const { data } = auth();
const token = request.cookies.get('authjs.session-token');
console.log('token', token);
console.log(data);
return NextResponse.next();
}
export const config = {
matcher: ['/login', '/signup'],
};
Код: Выделить всё
// auth.js
import NextAuth from 'next-auth';
import Credentials from 'next-auth/providers/credentials';
import { authorizeUser } from '@/lib/auth/user';
export const { auth, handlers, signIn, signOut } = NextAuth({
providers: [
Credentials({
credentials: {
email: {},
password: {},
},
authorize: authorizeUser,
}),
],
secret: process.env.NEXTAUTH_SECRET,
});
Код: Выделить всё
// next.config.mjs
/** @type {import('next').NextConfig} */
const nextConfig = {};
export default nextConfig;
Подробнее здесь: https://stackoverflow.com/questions/793 ... extauth-js