I am encountering a problem where environment variables are unexpectedly modified at runtime on my Appwrite server (version 1.6.0) hosted at https://custom-domain.tld. Here is the JavaScript configuration I'm using:
const client = new Client()
.setEndpoint(process.env.APPWRITE_FUNCTION_API_ENDPOINT)
.setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID)
.setKey(process.env.APPWRITE_FUNCTION_API_KEY);
The environment variable for the API endpoint is set as follows:
APPWRITE_FUNCTION_API_ENDPOINT="https://custom-domain.tld/v1"
Despite being correctly configured on the server, APPWRITE_FUNCTION_API_ENDPOINT changes to https:///v1 during runtime.
Using a hardcoded endpoint avoids this issue:
const client = new Client()
.setEndpoint("https://custom-domain.tld/v1")
.setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID)
.setKey(process.env.APPWRITE_FUNCTION_API_KEY);
Additionally, there was a protocol issue where, despite the endpoint protocol being set to https, it appeared to operate over http internally. I resolved this by enforcing HTTPS in the Appwrite environment settings:
_APP_OPTIONS_FORCE_HTTPS=enabled
I'm sharing this issue to find out if this behavior is intentional or if I might have misconfigured or misunderstood something. Any insights or similar experiences would be greatly appreciated.
Thanks a lot! ❤️
are you setting that environment variable inside the appwrite console?
i am setting it via the functions > settings > Environment variables:
I'm wondering if the issue is coming up because that environment variable is kinda like a reserved word and set automatically.
on local development it is set via the .env file and it is working fine
If you change it to something else, does it still get overwritten?
That environment variable is one that is set by appwrite at runtime, off the top of my head I don't know exactly how locally run functions work, but on the platform it's set. Could you see if changing it has any effect?
https://appwrite.io/docs/products/functions/develop#environment-variables
for me it looks like, that there is internally a function that wants to clear some parts like the protocol and if it is like the same host it tries to use just the short local url
ok, i understand, if this variable is available during runtime, this will not be overwritten by my .env, because it wants to use the internal one
i will test it tomorrow, if it will change with a different naming of the env variable
Recommended threads
- Deploying Function fails after several d...
I get the below issue on deploying to self hosted appwrite 1.8.0 functions, restarting the docker compose, or waiting a while, fixes it but is annoying. Any ide...
- OAuth login not working on deployed app ...
Hey there, I've been dealing with an issue where I cannot use OAuth on my deployed app - locally everything works fine. I am using react-router in Framework Mo...
- One org lost all data out of 13 org's af...
> https://<domain>/v1/storage/buckets?queries%5B0%5D=%7B%22method%22%3A%22limit%22%2C%22values%22%3A%5B6%5D%7D&queries%5B1%5D=%7B%22method%22%3A%22offset%22%2C%...