laravel-localization icon indicating copy to clipboard operation
laravel-localization copied to clipboard

hidden prefix redirection when locale cookie exist issue fixed

Open HasanQQ opened this issue 1 year ago • 0 comments

When "hideDefaultLocaleInURL" is true and we also want to use LocaleCookieRedirect middleware there is an issue happen. If users change their language with visiting prefixed route other than default locale (ex. https://example.com/es/foo-bar) then they want to revert again to the default language with visiting default prefixed (ex. https://example.com/en/foo-bar - en is default) route, LocaleCookieRedirect middleware redirecting them to "https://example.com/es/foo-bar" because of locale cookie (it's still "es"). So I added some rows to LaravelLocalizationRedirectFilter middleware for locale cookie update.

Also I change the http status code from 302 to 301 for this redirection because of this both page exactly the same (for SEO) and add "Pragma: no-cache" header for prevent browser cache issues.

HasanQQ avatar Aug 18 '22 16:08 HasanQQ