I use Ant Design Pro v4. After update umi version, env variables are returned undefined.
@xiaohuoni When will you solve this problem?
I have the same issue. Any help with this would be appreciated @xiaohuoni
How to reproduce it?
@sorrycc how to reproduce it?
Why use process.env? process.env.NODE_ENV should have defined.
@sorrycc I defined variables in .env file. But i cant reach these variables in js after update umijs.
api.js
const {REACT_APP_API } = process.env;
return callApi(${REACT_APP_API}/auth/token, {
method: 'GET',
});
.env
REACT_APP_API=https://blabla.com
@sorrycc ,
I Have Same Problem .
How can get .env file variables with process.env ?
@mohaphez @DanielFromTAFE @xiaohuoni use UMI_APP_* prefix instead of REACT_APP_* for env vars. I used that and worked!
For Example: REACT_APP_API ---- > UMI_APP_API
If you want to use REACT_APP_API, set the define in config file.
export default {
define: {
'process.env.REACT_APP_API': process.env.REACT_APP_API,
}
}
Most helpful comment
If you want to use REACT_APP_API, set the
definein config file.