Web3 getAccounts doesn't update when I switch Metamask addresses in browser

Solution 1:

TI think when the browser downloads anything, it caches, and fetch() is also caching the result. Change the options of fetch:

const response = await fetch(url, {
    method: 'GET',
    // this should invalidate caching
    cache: 'no-cache',     
    
  });

This should make a new request everytime you refresh the page