Is there a way for node to define a shared variable that can be used in the background and in the front end?

some variables are needed in the front and background, is there any way to set a shared variable?

for example, I define an is_debug variable, a configuration file at the front end and a configuration file at the back end. Every time I put it online, I have to change two copies, which is more tedious.

Apr.05,2021

the backend provides a dedicated api, front end to pull data from the backend.
if the front end initialization is to be used, the back end explicitly passes the value to the front end through ways such as url.
if it doesn't work, you can only manually change the build setting before the front-end build, and read the is_debug of the back-end project first

Things like

cookie also seem to work, depending on the timing you need at the front end

Menu