I am using the Stripe Payments plugin (from Strapi Marketplace) and within admin, in Settings > Payments Configuration
, a request is made to /strapi-stripe/getSettings
to load the values from the Strapi database.
Likewise, to save them by clicking the Save button, another request is made to /strapi-stripe/updateSetting
.
According to the plugin documentation, you have to create a token called STRAPI_ADMIN_API_TOKEN
in Settings > Global Settings > API Tokens
, save its value as an environment variable and do the corresponding npm run build
or yarn build
.
While everything works perfectly locally, when I deploy the application to Strapi Cloud, the request returns a 403. After a lot of research, I have discovered where the problem is but not the solution, because I think it is no longer up to me.
The value “Bearer undefined
” appears in the Authorization header of the request. By doing a multitude of tests, I have verified that this behavior is due to this file:
node_modules/strapi-stripe/admin/src/components/Configuration/index.js
In it there is a line where the environment variable is consulted:
const apiToken = process.env.STRAPI_ADMIN_API_TOKEN;
Which is later used to build the request using axios to /strapi-stripe/getSettings
. Such reading of process.env.STRAPI_ADMIN_API_TOKEN
returns undefined
.
I have created the environment variable in the deploy configuration in Strapi Cloud several times, I have deployed several times, I have tried countless things, including trying to inject the environment variable into the plugin through webpack, as they say here:
Finally, I have tried to deploy the project on Heroku and it actually works perfectly as well, therefore it is a problem with the Strapi Cloud environment.
However, I would like Strapi to give me a solution since otherwise I will be forced not to deploy to their infrastructure, since I need that plugin and I have no other alternatives.
Also, I suspect this could happen with other plugins so it doesn’t seem like a minor problem to me.