I am building a Wordpress site with Divi plugin and the project is hosted in an AWS Lightsail environment.
My ultimate goal is to make my Wordpress project use different environment variables in both testing and production environments. A button should contain a link to a different website based on the environment.
I have tried using the file wp-config.php, but I cannot get JavaScript to consume this file's environment variables (I have tried with process.env.[the name of the variable] and with other built-in functions of Wordpress and none worked).
Would you know how to do that? Should be straightforward. Thanks in advance!
The solution was quite simple. The file wp-config.php is not used to this end. You only have to follow the steps in: https://webdeasy.de/en/wordpress-php-variables-javascript/
It seems to be another way of passing variables, also defined directly on the Wordpress server.