I deployed an API made with Python/fastapi in Vercel. I'm using Tortoise orm and I have my DB connection ULR/string in an ENV variable. I am using a Postgres DB also hosted in Vercel linked with my project. When I try my code on my local server, my app works perfectly fine, it gets connected to the DB and I can execute queries without any issues. Here is a picture of the app working and the initialization that I have for Tortoise:
My problem is that, in the deployed application in Vercel, my app is not working due to a problem with the ENV variable, when I inspect the logs in my project dashboard in Vercel, I see this issue:
*[ERROR] KeyError: 'POSTGRES_URL' Traceback (most recent call last): File "/var/lang/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1030, in _gcd_import File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 850, in exec_module File "<frozen importlib._bootstrap>", line 228, in
_call_with_frames_removed File "/var/task/vc__handler__python.py", line 13, in <module>
__vc_spec.loader.exec_module(__vc_module) File "<frozen importlib._bootstrap_external>", line 850, in exec_module File "<frozen importlib._bootstrap>", line 228, in
_call_with_frames_removed File "./main.py", line 147, in <module>
db_url=credentials["POSTGRES_URL"],INIT_REPORT Init Duration: 2911.92 ms Phase: invoke Status: error Error Type: Runtime.ExitError Unknown application error occurred Runtime.Unknown*
I know that this means that the ENV variable is not being read, but I do not why because my ENV variable is declared in my project correctly (Actually, when I linked the Postgresql DB, all of the env variables were automatically loaded into the project in Vercel), so I already checked it and the value is correct:
Can somebody tell me what am I missing?
Note: I already tried with os.getenv("POSTGRES_URL") and with os.environ.get("POSTGRES_URL") and they also work in my local server but not in the deployed version, the project can't still read the env variable, which is why I'm also trying with the dotenv library right now, but it is also not working in the deployed version.

