Open layout-ch opened 5 months ago
I tried and I think the issue is not caused by the intergration but i a misconfiguration of your astro project. I tried everything to make your project work locally and failed, so i started a brand new following i18n docs then sanity docs. It works perfectly fine https://github.com/florian-lefebvre/astro-i18n-sanity-test
Hi Florian,
I'm reopening this issue as I've managed to identify the cause of the problem. It appears that using <I18NHead />
is causing the conflict with the Sanity integration.
I downloaded your minimal reproduction and added the <I18NHead />
component. Locally, npm run dev works without issues on my Mac. However, deploying to Vercel results in the /admin route becoming inaccessible.
On Vercel you get a status 500 when trying to access the /admin
route followed by this error :
20:47:21 [ERROR] TypeError: als.run is not a function at file:///var/task/vercel/path0/.vercel/output/_functions/chunks/_astro-internal_middleware_Cor_ETLZ.mjs:50:14 at applyHandle (file:///var/task/vercel/path0/.vercel/output/_functions/chunks/_astro-internal_middleware_Cor_ETLZ.mjs:17:22) at file:///var/task/vercel/path0/.vercel/output/_functions/chunks/_astro-internal_middleware_Cor_ETLZ.mjs:14:12 at applyHandle (file:///var/task/vercel/path0/.vercel/output/_functions/chunks/_astro-internal_middleware_Cor_ETLZ.mjs:17:22) at file:///var/task/vercel/path0/.vercel/output/_functions/chunks/_astro-internal_middleware_Cor_ETLZ.mjs:19:18 at payload (file:///var/task/vercel/path0/.vercel/output/_functions/entry.mjs:35:25) at applyHandle (file:///var/task/vercel/path0/.vercel/output/_functions/chunks/_astro-internal_middleware_Cor_ETLZ.mjs:17:22) at file:///var/task/vercel/path0/.vercel/output/_functions/chunks/_astro-internal_middleware_Cor_ETLZ.mjs:14:12 at callMiddleware (file:///var/task/vercel/path0/.vercel/output/_functions/entry.mjs:691:27) at RenderContext.render (file:///var/task/vercel/path0/.vercel/output/_functions/entry.mjs:1181:28)
Additionally, attempting to run npm run dev on StackBlitz throws an error: 22:55:09 [ERROR] Cannot read properties of undefined (reading 'data') Stack trace: at getLocales (i18n:astro:149:21)
Here are the links for reference:
My minimal reproduction with
I'm investigating and the issue seems unrelated to sanity. on windows i have no issue with the als but on stackblitz (linux) the als getStore is undefined
https://stackblitz.com/edit/github-ddc8wy?file=src%2Froutes%2Findex.astro this logs undefined
but it should be an object. Works locally on windows so maybe an os thing or node version thing? Can someone try it on a linux or a mac to see if it happens as well? Related source code available here:
on my mac I dont get any errors and that's what I get from the log :
{
clientOptions: { data: false, translations: false, paths: false },
translations: {
initialized: false,
i18nextConfig: {
namespaces: [Array],
defaultNamespace: 'common',
resources: [Object]
}
},
data: { locale: 'en', locales: [ 'en', 'fr' ], defaultLocale: 'en' },
paths: {
pathname: '/',
routes: [ [Object], [Object] ],
dynamicParams: {},
strategy: 'prefixExceptDefault'
}
}
I didn't update the issue but this error is stackblitz specific, I'll see about vercel tomorrow
Hi! The integration works like a charm with Astro. Now I'm trying to do the next step which is adding a CMS so that clients can handle their multilanguage website through a Dashboard.
For this I'm trying out Sanity with has a super generous free tier. I did a small repro here with astrolicious-i18n: https://github.com/layout-ch/astro-sanity .
Sanity let you embed your cms on a route of your website, which I did on the
/admin
route in theastro-config
:export default defineConfig({ site: "https://test.com", output: "hybrid", adapter: vercel(), integrations: [ sanityIntegration( { projectId: "t9cmnozc", dataset: "production", useCdn: false, studioBasePath: "/admin", } ), react(), liciousI18n({ defaultLocale: "fr", locales: ["fr", "de", "en"], strategy: "prefix", sitemap: true, pages: { "a-propos": { de: "ueber-uns", en: "about-us" } } })] });
It works like intended on the dev server but when I deploy to vercel, vercel doesn't seem to like that.
I tried it out without astrolicious-i18n and it works, but once I added the integration to the project, I get a
status 500
on the/admin
route. Is this because of how astrolicious-i18n handles the routes? Since they are generated automatically on build time, it somehow overrides the /admin route that comes from the sanity integration? Any tips on how to make this work with a headless CMS would be amazing. Thank you in advance !Side note : everything works when I remove i18n so it is somehow interfering somewhere....