fix(auth): restore middleware, fix setup redirect loop, and add next.config rewrites proxying Supabase requests
All checks were successful
Staging Build / build (push) Successful in 3m27s
All checks were successful
Staging Build / build (push) Successful in 3m27s
This commit is contained in:
@@ -55,6 +55,7 @@ export async function updateSession(request: NextRequest) {
|
|||||||
request.nextUrl.pathname !== "/" &&
|
request.nextUrl.pathname !== "/" &&
|
||||||
request.nextUrl.pathname !== "/impressum" &&
|
request.nextUrl.pathname !== "/impressum" &&
|
||||||
request.nextUrl.pathname !== "/datenschutz" &&
|
request.nextUrl.pathname !== "/datenschutz" &&
|
||||||
|
request.nextUrl.pathname !== "/setup" &&
|
||||||
!user &&
|
!user &&
|
||||||
!request.nextUrl.pathname.startsWith("/login") &&
|
!request.nextUrl.pathname.startsWith("/login") &&
|
||||||
!request.nextUrl.pathname.startsWith("/auth")
|
!request.nextUrl.pathname.startsWith("/auth")
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { updateSession } from "@/lib/supabase/proxy";
|
import { updateSession } from "@/lib/supabase/proxy";
|
||||||
import { type NextRequest } from "next/server";
|
import { type NextRequest } from "next/server";
|
||||||
|
|
||||||
export async function proxy(request: NextRequest) {
|
export async function middleware(request: NextRequest) {
|
||||||
return await updateSession(request);
|
return await updateSession(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,6 +25,23 @@ const nextConfig: NextConfig = {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
async rewrites() {
|
||||||
|
const supabaseUrl = (process.env.SUPABASE_URL || "http://supabase-kong:8000").replace(/\/$/, "");
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
source: '/auth/v1/:path*',
|
||||||
|
destination: `${supabaseUrl}/auth/v1/:path*`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
source: '/rest/v1/:path*',
|
||||||
|
destination: `${supabaseUrl}/rest/v1/:path*`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
source: '/storage/v1/:path*',
|
||||||
|
destination: `${supabaseUrl}/storage/v1/:path*`,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default nextConfig;
|
export default nextConfig;
|
||||||
|
|||||||
Reference in New Issue
Block a user