[英]How do I change the api addresses in the build of the React project?
In my React project, I want to change the api addresses after build it.在我的 React 项目中,我想在构建后更改 api 地址。 I want to be able to change their address dynamically.
我希望能够动态更改他们的地址。 is There a way I can do this?
有没有办法我可以做到这一点? I do not want to use the environment.
我不想使用环境。 Because when I get build, I can not change api address
因为当我构建时,我无法更改 api 地址
Use the NODE_ENV env variable to check the environment使用 NODE_ENV 环境变量检查环境
if (process.env.NODE_ENV === 'production') {
// Set the API URL for prod
}
Set NODE_ENV=production
when running your build script运行构建脚本时设置
NODE_ENV=production
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.