patryk
patryk
DTDrizzle Team
Created by patryk on 9/8/2024 in #help
Error: The edge runtime does not support Node.js 'crypto' module.
import NextAuth from "next-auth";
import authConfig from "@/auth.config";

import {
DEFAULT_LOGIN_REDIRECT,
apiAuthPrefix,
authRoutes,
publicRoutes
} from "@/routes";

const { auth } = NextAuth(authConfig);

export default auth((req) => {
const { nextUrl } = req;
const isLoggedIn = !!req.auth;

const isApiAuthRoute = nextUrl.pathname.startsWith(apiAuthPrefix);
const isPublicRoute = publicRoutes.includes(nextUrl.pathname);
const isAuthRoute = authRoutes.includes(nextUrl.pathname);

if (isApiAuthRoute) return null;

if(isAuthRoute) {
if (isLoggedIn) return Response.redirect(new URL(DEFAULT_LOGIN_REDIRECT, nextUrl));
else return null;
}

if(!isLoggedIn && !isPublicRoute) return Response.redirect(new URL("/auth/login", nextUrl));
else return null;
})

export const config = {
matcher: [
'/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)',
'/(api|trpc)(.*)',
],
};
import NextAuth from "next-auth";
import authConfig from "@/auth.config";

import {
DEFAULT_LOGIN_REDIRECT,
apiAuthPrefix,
authRoutes,
publicRoutes
} from "@/routes";

const { auth } = NextAuth(authConfig);

export default auth((req) => {
const { nextUrl } = req;
const isLoggedIn = !!req.auth;

const isApiAuthRoute = nextUrl.pathname.startsWith(apiAuthPrefix);
const isPublicRoute = publicRoutes.includes(nextUrl.pathname);
const isAuthRoute = authRoutes.includes(nextUrl.pathname);

if (isApiAuthRoute) return null;

if(isAuthRoute) {
if (isLoggedIn) return Response.redirect(new URL(DEFAULT_LOGIN_REDIRECT, nextUrl));
else return null;
}

if(!isLoggedIn && !isPublicRoute) return Response.redirect(new URL("/auth/login", nextUrl));
else return null;
})

export const config = {
matcher: [
'/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)',
'/(api|trpc)(.*)',
],
};
3 replies
DTDrizzle Team
Created by patryk on 2/4/2024 in #help
Troubles during migrations using drizzle and a neon serverless database
nevermind i fixed it but i'll leave the ticket here. i added this to my migrate.ts
import * as dotenv from 'dotenv';

dotenv.config({
path: '.env.local',
});
import * as dotenv from 'dotenv';

dotenv.config({
path: '.env.local',
});
6 replies
DTDrizzle Team
Created by patryk on 2/4/2024 in #help
Troubles during migrations using drizzle and a neon serverless database
my .env.local is setup as it should i think DATABASE_URL=postgresql://user:password@thehost/mydbname
6 replies