Disable the frontend in Magento 2 for using only the Admin and the API routes.
Install Disable Frontend for Magento2
- Download the extension
- Unzip the file
- Create a folder {Magento root}/app/code/Abelbm/DisableFrontend
- Copy the content from the unzip folder
composer require abelbm/magento2-disablefrontend
- php bin/magento module:enable Abelbm_DisableFrontend
- php bin/magento setup:upgrade
- php bin/magento cache:flush
- php bin/magento setup:di:compile
Stores > Configuration > Advanced > Admin > Disable Frontend