Open Pierre-Demessence opened 5 days ago
Hello @Pierre-Demessence please checkout this example repository:
https://github.com/gzimbron/example-env-variables-amplify-adapter
You need to add Environment variables in amplify app control panel
You need to add Environment variables in amplify app control panel
Yes, they have been added.
I've checked your repo and I do exactly the same, aside from using dynamic env instead of static env. So I tried, and it appears it works for static env.
So this doesn't work:
import { env } from '$env/dynamic/public';
console.log('DYANMIC SVELTE_APP_API_ENDPOINT', env.SVELTE_APP_API_ENDPOINT); // undefined
But this works:
import * as env_static from '$env/static/public';
console.log('STATIC SVELTE_APP_API_ENDPOINT', env_static.SVELTE_APP_API_ENDPOINT); // correct value
As you can see I have changed the prefix to SVELTE_APP_
(for retro-compatibility), but I doubt that's the issue.
I have a solution right now by switching to static env, but since I might need dynamic variables, I don't think the issue is solved yet.
It seems that, for now, you can only use static variables, since AWS Amplify uses a Docker image (Amazon Linux 2023). Unless you use a custom image, it doesn’t seem possible to add environment variables to the image.
Hello, I'm using dynamic public variables:
It's working with an
.env
or.env.local
file when building withnpm run dev
andnpm run preview
. But once it's deployed on Amplify, it's not working, the variables are empty. I tried to set the following variables on Amplify panel:API_ENDPOINT
SVELTE_APP_API_ENDPOINT
PUBLIC_API_ENDPOINT
VITE_API_ENDPOINT
I also tried what's written on Amplify doc: https://docs.aws.amazon.com/amplify/latest/userguide/ssr-environment-variables.html Tried putting the
.env.production
inside the build folder.Nothing has worked for now. I've checked with an
.env
command in the build steps inamplify.yml
and the variables exist.Versions: