Strapi NOT including my ENV variables when deploying to Strapi Cloud

System Information
  • Strapi Version: ^4.24.5
  • Operating System: Windows
  • Database: Postgress
  • Node Version: >=18.0.0 <=20.x.x
  • NPM Version: >=6.0.0
  • Yarn Version:

When I build locally, I can see this:

Building build context[INFO] Including the following ENV variables as part of the JS bundle:
    - ADMIN_PATH
    - STRAPI_ADMIN_BACKEND_URL
    - STRAPI_TELEMETRY_DISABLED
    - STRAPI_ADMIN_API_TOKEN
    - STRAPI_ADMIN_CD_PASS
    - STRAPI_ADMIN_CD_TOKEN
    - STRAPI_ADMIN_CD_USER

However when I deploy to Strapi Cloud, I can see in the build logs this:

[INFO] Including the following ENV variables as part of the JS bundle:
[2024-11-18 01:22:26] │     - ADMIN_PATH
[2024-11-18 01:22:26] │     - STRAPI_ADMIN_BACKEND_URL
[2024-11-18 01:22:26] │     - STRAPI_TELEMETRY_DISABLED

Why is Strapi not including ALL of my ENV variables in the Strapi Cloud deployment?
I’d like to access them in the Strapi Cloud deployment.

I have not found a solution but I did find a workaround…

The ENV variables seem to be accessible from an API Controller. Something like this: /api/[API_NAME]/controllers/[API_NAME].js

Therefore, I have created an API endpoint called api/get-env-vars which is auth protected etc.

This endpoint returns all the required ENV variables.

Once logged into the Strapi Cloud backend, this end point is called on the server, grabs the ENV variables and stores them for use throughout the Strapi Cloud backend.

Hope this helps somebody.