Skip to content
Discussion options

You must be logged in to vote

Thanks to @amannn's guide, I've worked it out, the key is middleware.ts

import createMiddleware from "next-intl/middleware";

export default createMiddleware({
    locales: ["en", "de", "fr", "es", "it", "ja", "nl", "pl", "pt", "ru", "sv"],
    // 'as-needed' should pass to createMiddleware
    localePrefix: 'as-needed',
    defaultLocale: "en",
});

export const config = {
    // We should skip the internal routes
    matcher: ["/((?!api|static|.*\\..*|_next).*)", '/(zh-CN|en)/:path*']
};

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
4 replies
@stylehuan
Comment options

@amannn
Comment options

@stylehuan
Comment options

@shiny
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by sachithrrra
Comment options

You must be logged in to vote
2 replies
@amannn
Comment options

@SamX23
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants