简体   繁体   English

为每个环境电子反应应用程序设置变量

[英]Setting variables per environment electron-react app

its the first time i do electron app, this app need to do API calls to lets say: 这是我第一次使用电子应用程序,该应用程序需要执行API调用,可以说:

http:/<baseUrl>/someAPI

I need to change this "baseURL" on build somehow. 我需要以某种方式更改此“ baseURL”。 (can be anything...) and cant use System.env when app is build. (可以是任何内容...),并且在构建应用程序时无法使用System.env。 i am using electron builder 我正在使用电子助剂

I am thinking about creating a script and adding it to "package.json", any thing more simple? 我正在考虑创建脚本并将其添加到“ package.json”,还有什么更简单的事情吗?

Thanks! 谢谢!

you can use proxy in package.json Example "proxy": "http://example.com" so in each HTTP request will assign this proxy in the URL. 您可以在package.json使用代理package.json示例"proxy": "http://example.com"因此在每个HTTP请求中都会在URL中分配此代理。 or you can use this package electron-proxy-agent 或者您可以使用此包装的电子代理

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM