opral / inlang-paraglide-js

Tree-shakable i18n library build on the inlang ecosystem.
https://inlang.com/m/gerre34r/library-inlang-paraglideJs
52 stars 1 forks source link

[Paraglide-Next] Disable NEXT_LOCALE cookie #246

Open chrisallday-dev opened 1 month ago

chrisallday-dev commented 1 month ago

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 commented 1 month ago

Not that I am aware of. Will put this on the metaframework overhaul project https://github.com/opral/inlang-paraglide-js/issues/217