Deploying needs one thing beyond your usual setup: UNIVERSALLY_API_KEY has to be set in the environment where the build runs, not only where the server runs. The integration reads the key when your Astro config runs and compiles it into the server bundle. It never reaches the client bundle.
Bevor Sie beginnen
- The site works locally. See Install the Astro integration.
siteinastro.config.mjsis your production domain, so hreflang links point at it.- You have the 64 character API key from API Settings. See Find your API key.
Set the key for your host
Your .env file stays out of the repository, so the build machine needs the variable from somewhere else. .env.production and other mode files are not read.
- Node: set
UNIVERSALLY_API_KEYin the shell, systemd unit, or container environment that runs the build, then start the server the adapter produced. - Cloudflare: set it as a build environment variable in the Workers or Pages build settings. Where the runtime exposes
waitUntil, the integration uses it, so reports and reloads finish after the response instead of being cut off. - Vercel: add it under the project's environment variables, for every environment you build.
- Netlify: add it under the site's environment variables, available at build time.
Never put the key in a PUBLIC_ variable, in a client component, or in committed code. It can spend your project's words.
Deploy
- Set the variable as above.
- Run your usual build and deploy.
- Open a page under a target prefix, such as
https://example.com/fr/about. The built Node server loads its catalog on the first localized request, so that one request is slower.
A static build prints N new strings translated. Rebuild to include them. when it finds new text. Build and deploy again to ship those translations.
Make the push endpoint reachable
For dashboard edits to show straight away, https://{your domain}/_universally/revalidate has to accept POST requests from the internet. The integration answers it before Astro routing, so you add no page or route. If the endpoint is behind a firewall or login, polling still picks the edit up within revalidateSeconds. See Translation updates in Astro.
Static sites have no push endpoint. Rebuild and redeploy to publish dashboard edits.
Several instances
Each server instance keeps its own catalog in memory. A push reaches one instance, and the rest catch up by polling. Set revalidateSeconds to a delay you accept. See Astro integration options.
After regenerating the key
Regenerieren in den API-Einstellungen macht den alten Schlüssel sofort ungültig. Aktualisieren Sie UNIVERSALLY_API_KEY auf Ihrem Host und stellen Sie ihn erneut bereit, andernfalls schlägt der nächste Build fehl und der Push-Endpunkt eines laufenden Servers gibt 401 zurück.
Überprüfen Sie, ob es funktioniert hat
- Die bereitgestellte Seite unter
/fr/zeigt nach einem Neuladen übersetzten Text an. - Die Seitenquelle enthält ein
<link rel="alternate" hreflang>pro Sprache mit Ihrer Produktionsdomäne. - Bearbeiten Sie eine Zeichenfolge auf dem Bildschirm Übersetzungen und laden Sie die Seite dann neu. Die Bearbeitung wird sofort angezeigt, wenn der Push Sie erreicht hat, oder innerhalb von
revalidateSeconds, wenn das Abrufen sie erkannt hat.