Use .env in local plugin

Unfortunately not, I would imagine you don’t want that API leaked in the build and it would be better in your case I think to construct an API controller in the plugin backend to handle the request and forward the response to your plugin frontend.

If the key environment variable isn’t included during build time (of the admin and the plugin admin) the frontend won’t be able to access the variable. The only other method is to request it from the Strapi backend or have the backend make the request.

Our admin is React based and thus is CSR (Client Side rendered) meaning once it’s built Strapi is only acting as a static web server for the built files.

3 Likes