solved - Localized data from CMS API and i18n behaviour
Hello! I have a question regarding the i18n module when fetching data from an api (graphql endpoint from Directus CMS).
I'm sending my graphql requests from the
useAsyncData
composable (https://nuxt-graphql-request.vercel.app/usage/components)
I'm using the locale
from useI18n
as a graphql variable to only fetch the correct translations.
It works when I generate the static website, but in dev mode the distant translations are not updated when changing locales (with a language switcher from the docs). I have to reload the page to see the correct translations, which is not ideal.
I tried using a watcher both inside and outside of the function to refresh the query but no luck…
Is this expected? Thanks!
edit: might be related to this https://github.com/nuxt-modules/i18n/issues/2377 ?
edit 2: might also be related to CORS (console error of Allow Origin and then Preflight Did Not Succeed when I allowed localhost)Nuxt GraphQL Request
Components
GitHub
locale
changes BEFORE the route path does, which causes issues wi...Environment Operating System: Linux Node Version: v18.16.0 Nuxt Version: 3.7.1 CLI Version: 3.7.3 Nitro Version: 2.6.2 Package Manager: [email protected] Builder: - User Config: extends, telemetry, ssr, ...
1 Reply
it was a CORS error as directus does not allow the "options" method by default.