Skip to content

Support passing locale by state/cookie #542

Answered by EliasVal
EliasVal asked this question in Q&A
Discussion options

You must be logged in to vote

Oh! managed to figure out a solution.

first, my Regex was faulty, so now changed it to:

export const config = {
  matcher: ['/((?!_next|assets).*)'],
};

And the middleware was still redirecting by the locale so I have used this to go around it:

import createIntlMiddleware from 'next-intl/middleware';
import { NextRequest } from 'next/server';

export default async function middleware(request: NextRequest) {
  const defaultLocale = request.headers.get('x-default-locale') || 'he';

  const handleI18nRouting = createIntlMiddleware({
    locales: ['he', 'en', 'ar'],
    defaultLocale,
    localePrefix: 'never',
    alternateLinks: false,
    localeDetection: false,
  });
  const response = ha…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@EliasVal
Comment options

@EliasVal
Comment options

Answer selected by EliasVal
@amannn
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
enhancement New feature or request unconfirmed Needs triage.
2 participants
Converted from issue

This discussion was converted from issue #539 on October 02, 2023 15:07.