EatTheBlocks Forum

Can not get address from web3 in production

Hi, I am working on the project. finally, everything is working but except when I deploy my react app on gcp, it can’t get an address from the user’s browser. Everything works great in development but scrws up in production.

export const web3Enabled = async () => {
    var web3 = window.web3
    if(typeof web3 !== 'undefined' || window.ethereum) {
        web3 = new Web3(window.ethereum)
        await window.ethereum.enable()
        return true
    }else{
        return false
    }
}

let from = await window.web3.eth.accounts[0]

I have tried getAccounts(). It didn’t work. So, I switched back to acctount[0]