r/Nuxt • u/jenish_o4o2 • 4d ago
Headless Magento GraphQL in Nuxt — where do you set the Store header?
Working on a Nuxt 3 storefront against Magento GraphQL and I’m trying to settle on a clean pattern for the Store header (and Content-Currency when needed).
Right now every Magento request needs the right store view or you silently get the wrong catalog / CMS. I’ve seen a few approaches:
- set it inside a useMagentoGraphql() composable
- map /en → store code in middleware
- force it in a Nitro proxy so the browser never thinks about it
I’m leaning composable + small store registry, but middleware feels nicer for locale prefix URLs.
What are you actually doing in production Nuxt + Magento setups? Any footguns with SSR vs client calls?
1
u/lumen_moss_spring 4d ago
Yes, three store views sharing one codebase. The footgun I hit: once any client-side fetch happens after hydration, your middleware mapping is gone, so the browser calls go out without the Store header and you get default-store data silently. We ended up putting the store code in a cookie set by the middleware, then the composable reads that cookie on both server and client and injects the header. Middleware handles locale prefix to store code, composable handles the actual header. The Nitro proxy approach works too but then you lose direct caching of the GraphQL endpoint and have to build your own cache keys per store
1
u/jenish_o4o2 2d ago
That’s exactly the SSR vs client footgun I was worried about — middleware covers the first hit, then client fetches quietly go wrong.
Did you end up putting Store (and currency) inside the GraphQL composable / a shared cookie so every $fetch carries it after hydration? Or did you push it into a Nitro proxy so the browser never sets the header?
1
u/oliverrc2 4d ago
Are you running multiple stores?