Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Paraglide-Next] Disable NEXT_LOCALE cookie #246

Open
chrisallday-dev opened this issue Oct 17, 2024 · 1 comment
Open

[Paraglide-Next] Disable NEXT_LOCALE cookie #246

chrisallday-dev opened this issue Oct 17, 2024 · 1 comment

Comments

@chrisallday-dev
Copy link

Hi, is there a way to disable the NEXT_LOCALE cookie that gets created when using paraglide with the App Router? Currently we have tried to remove it via the middleware and even though it is no longer present in the browser, it still get's detected by cookie scanners.

TLDR - Add cookie or disableCookie property to Middleware options?

Can we remove this entirely somehow, perhaps via a config here:

export const middleware = Middleware({ cookie: false, strategy }); // Something like this?

Here is the code that removes it currently:

import { middleware as i18nMiddleware } from 'i18n';
import { type NextRequest } from 'next/server';

export function middleware(request: NextRequest) {
  const locale = i18nMiddleware.detectLanguage(request);

  const response = i18nMiddleware.getResponse(request, locale);

  response.cookies.delete('NEXT_LOCALE');

  return response;
}

export const config = {
  matcher: [
    // Skip Next.js internals and all static files, unless found in search params
    '/((?!_next|animations|[^?]*\\.(?: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)(.*)',
  ],
};
@samuelstroschein
Copy link
Member

Not that I am aware of. Will put this on the metaframework overhaul project #217

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants