-
Is your feature request related to a problem? Please describe.Can someone show how to combine the middlaware needed for supabase (auth-helpers-nextjs) with next-int? Describe the solution you'd likeSupabase middleware: import type { NextRequest } from "next/server"; export async function middleware(req: NextRequest) { // Create a Supabase client configured to use cookies // Refresh session if expired - required for Server Components return res; Describe alternatives you've consideredNext-intl middleware: `import createMiddleware from 'next-intl/middleware'; export default createMiddleware({ // If this locale is matched, pathnames work without a prefix (e.g. export const config = { |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
Based on their docs, I imagine that something like this could work: import createIntlMiddleware from 'next-intl/middleware';
import {NextRequest} from 'next/server';
export default async function middleware(req: NextRequest) {
const handleI18nRouting = createIntlMiddleware({
locales: ['en', 'de'],
defaultLocale: 'en'
});
const res = handleI18nRouting(request);
const supabase = createMiddlewareClient({ req, res })
await supabase.auth.getSession()
return response;
}
export const config = {
matcher: ['/((?!_next|.*\\..*).*)']
}; I'll convert this to a discussion since this is a usage question. |
Beta Was this translation helpful? Give feedback.
-
For anyone having the same problem, take a look at my code. I don't know if it is bullet proof but works fine for now.
My AppConfig looks like this:
|
Beta Was this translation helpful? Give feedback.
-
The solution for this is now documented in the next-intl documentation. Scroll down to the section titled "Example: Integrating with Supabase Authentication". Here's the excerpted code in case the page goes away.
|
Beta Was this translation helpful? Give feedback.
Based on their docs, I imagine that something like this could work:
I'll convert this to a discussion since this is a usage question.