Skip to content

Twice 302 Redirect, Unable to access the app's default language #929

@szwss

Description

@szwss

Hello, thank you very much for providing this package; it has been very helpful to me.

I am currently using Laravel 8 and have installed "mcamara/laravel-localization": "^2.0.1".

Problem Description:

app.locale is set to ja.

Package Configuration:

supportedLocales includes en, ja, and zh-CN.
'useAcceptLanguageHeader' => true,
'hideDefaultLocaleInURL' => true.

Browser:

accept-language: zh-CN,zh;q=0.9

Accessing:

When I access /ja, since ja is the default language, it automatically redirects to / with a 302 status.

This means the system detects that there is no language parameter, then immediately triggers another 302 redirect to the browser's preferred language based on the header.

Question:

Is there an issue with this process? When I want to access the app's default language, due to the browser's header settings, I am unable to access the app's default language at all.

Idea:

Could we check if the request is coming from a 302 redirect? If so, we should not perform another redirect to prevent the situation mentioned above. Alternatively, we could add a configuration option (true or false) that allows developers to decide whether to enable this feature or not.

I am not sure if my concern is valid or if my proposed solution is feasible. Thank you again for providing this package!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions