Next.js Discord

Discord Forum

Apple Web App Redirects

Unanswered
Khao (Ping on reply) posted this in #help-forum
Open in Discord
When I get redirected iOS thinks it's an external redirect but it's actually in the same URL just in a different path, is there anyway to bypass this?

My middleware doing the redirects:
import { auth } from "@/auth"
import authConfig, { authRoutes } from "./auth.config";
import { NextResponse } from "next/server";
export const middleware = auth(async (req) => {
    const dashboardURL = req.nextUrl.clone()
    dashboardURL.pathname = '/';
    if (req.auth && req.nextUrl.pathname === authConfig.pages.signIn)
        return NextResponse.redirect(dashboardURL)
    if ((!req.auth && !authRoutes.includes(req.nextUrl.pathname)) || (!req.auth && req.nextUrl.pathname === authConfig.pages.signOut)) {
        const url = req.nextUrl.clone();
      url.pathname = authConfig.pages.signIn;
    return NextResponse.redirect(url)
  }
    return NextResponse.next();
});

export const config = {
  matcher: ["/((?!api|_next/static|_next/image|favicon.ico).*)"],
}

0 Replies