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

Allow setting detectBrowserLanguage.cookieDomain by runtimeConfig #2761

Open
3 of 4 tasks
blu14x opened this issue Feb 7, 2024 · 2 comments
Open
3 of 4 tasks

Allow setting detectBrowserLanguage.cookieDomain by runtimeConfig #2761

blu14x opened this issue Feb 7, 2024 · 2 comments

Comments

@blu14x
Copy link

blu14x commented Feb 7, 2024

Describe the feature

Heyho

Currently we can specify the cookieDomain in the nuxt.config.ts to bake it into the NuxtI18nOptions, or leave it null so it defaults to the host.

Problem

Sometimes, however, if it is used in several different deployments, it may be necessary to adapt the domain for the cookie accordingly. But right now, it is not possible to customise the domain for different deployments.

Solution

Introduce an environment variable, similar to baseUrl, to change the value for cookieDomain during runtime.
Suggestion: NUXT_PUBLIC_I18N_COOKIE_DOMAIN

The icing on the cake would be that the option accepts a function with the context as a parameter that returns either the domain string or null.

Additional information

  • Would you be willing to help implement this feature?
  • Could this feature be implemented as a module?

Final checks

@blu14x blu14x changed the title Allow setting **detectBrowserLanguage.cookieDomain** by **runtimeConfig** Allow setting detectBrowserLanguage.cookieDomain by runtimeConfig Feb 7, 2024
@BobbieGoede
Copy link
Collaborator

I have worked on runtimeConfig support for the detectBrowserLanguage a while ago (#2576) but unfortunately it's blocked until the next nitropack release which includes nitrojs/nitro#1831. I'll update/sync the feature PR soon, I think the next nitropack release will be sometime this month.

The icing on the cake would be that the option accepts a function with the context as a parameter that returns either the domain string or null.

This wouldn't be possible using runtimeConfig as functions are not serializable, I'm also a bit hesitant to add function support in the options as the same support for baseUrl has been a source of issues, though it's not out of the question if it is a common request.

@blu14x
Copy link
Author

blu14x commented Feb 7, 2024

I have worked on runtimeConfig support for the detectBrowserLanguage a while ago (#2576) ...

Oh awesome. I quickly skimmed through that.
That would be even better than just handling individual options of detectBrowserLanguage.

If I understand correctly, this would allow:

export default defineNuxtConfig({
  runtimeConfig: {
    public: {
      i18n: {
        detectBrowserLanguage: {
          cookieDomain: null,
        },
      },
    },
  },
})

Which makes it overwritable by NUXT_PUBLIC_I18N_DETECT_BROWSER_LANGUAGE_COOKIE_DOMAIN.

I guess?

@BobbieGoede BobbieGoede removed the v8 label Nov 4, 2024
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