最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

next.js - Combining clerk middleware with next-intl middleware - Stack Overflow

programmeradmin0浏览0评论

Newbie Next dev here. How do I combine these in src/middleware.ts

import createMiddleware from 'next-intl/middleware';
import {routing} from './i18n/routing';
 
export default createMiddleware(routing);
 
export const config = {
  matcher: ['/', '/(mn|en)/:path*']
};

and

import { clerkMiddleware } from "@clerk/nextjs/server";

export default clerkMiddleware();

export const config = {
  matcher: [
    // Skip Next.js internals and all static files, unless found in search params
    '/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)',
    // Always run for API routes
    '/(api|trpc)(.*)',
  ],
};

I found this from next-intl doc /docs/routing/middleware ` import {clerkMiddleware, createRouteMatcher} from '@clerk/nextjs/server'; import createMiddleware from 'next-intl/middleware'; import {routing} from './i18n/routing';

const handleI18nRouting = createMiddleware(routing);

const isProtectedRoute = createRouteMatcher(['/:locale/dashboard(.*)']);

export default clerkMiddleware((auth, req) => { if (isProtectedRoute(req)) auth().protect();

return handleI18nRouting(req); });

export const config = { matcher: ['/', '/(de|en)/:path*'] };` but getting this type issue "Property 'protect' does not exist on type 'Promise'"

发布评论

评论列表(0)

  1. 暂无评论