This issue can be fixed by issuing the following queries
UPDATEstore
SET store_id = 0 WHERE code='admin';
UPDATEstore_group
SET group_id = 0 WHERE name='Default';
UPDATEstore_website
SET website_id = 0 WHERE code='admin';
It can also be solved by modify StoreManager.php (/vendor/magento/module-store/Model/StoreManager.php)
If $storeId is not defined: It retrive data from COOKIE first, otherwise return the default store code.
if (!isset($storeId) || '' === $storeId || $storeId === true) {
if (null === $this->currentStoreId) {
\Magento\Framework\Profiler::start('store.resolve');
$this->currentStoreId = $this->storeResolver->getCurrentStoreId(); \Magento\Framework\Profiler::stop('store.resolve');
}
$storeId = $this->currentStoreId;
}
To
if(!$storeId) {
if(isset($_COOKIE['store']) && $_COOKIE['store'] !== ''){
$storeId = $_COOKIE['store'];
} else {
$storeId = $this->getDefaultStoreView()->getCode();
}
}