Skip to content

How to configure Resend provider #12045

Answered by Goldziher
Goldziher asked this question in Help
Discussion options

You must be logged in to vote

I solved this,

the solution is to cheat in the middleware:

import { MiddlewareConfig, NextResponse } from "next/server";
import { PagePath } from "@/enums";
import NextAuth from "next-auth";

const { auth } = NextAuth({ providers: [] });

export const middleware = auth(async (req) => {
	const path = new URL(req.url).pathname;

	const session = await auth();

	const isSigninPage = path === PagePath.SIGNIN.toString();
	const isRootPage = path === PagePath.ROOT.toString();
	const isAPIRoute = path.startsWith("/api");

	if (session && isSigninPage) {
		return NextResponse.redirect(new URL(PagePath.ROOT, req.url));
	}

	if (!session && !(isRootPage || isSigninPage || isAPIRoute)) {
		return Ne…

Replies: 1 comment

Comment options

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