shkoliar / magento-ngrok

Magento 2 module for ngrok.io service support
https://shkoliar.com
MIT License
44 stars 22 forks source link

Not working with paths #5

Open ioan-ghisoi-cko opened 4 years ago

ioan-ghisoi-cko commented 4 years ago

I have Magento installed on localhost/magento2, and when I use this with ngrok it sets the base URL without /magento2 and it breaks the links

Thisura98 commented 3 years ago

Hello! I got this to work using a really dirty hack. It uses also suggestions from Issue #3. Enter the commands in your Terminal.

  1. If you're using a special Magento user, switch to that user using the "su" command. Otherwise, skip this step.
  2. In your Magento root directory, type in find . -name 'StoreBaseUrl.php'. This finds the path to the file we need to modify.
  3. Type in vim ./vendor/shkoliar/magento-ngrok/Plugin/Model/StoreBaseUrl.php and Enter.
  4. Focus to the 51th by entering :51 (with the colon ':') in vim.
  5. Enter INSERT mode in vim using by pressing the i key.
  6. Comment the 51th line by adding two forward slashes (//) before anything on that line.
  7. Go to the end of the commented line and hit the Enter key to create a new line.
  8. Add the following line. return $protocol . $ngrokDomain . DIRECTORY_SEPARATOR . 'magento2' . DIRECTORY_SEPARATOR;

    NOTE: Replace "magento2" with your Magento root's path. @ioan-ghisoi-cko's Magento is installed in "localhost/magento2" so I am assuming "magento2" is where Magento is installed.

  9. Final result should look like this. Screenshot from 2021-05-09 19-30-06
  10. Hit the Escape key, then :wq, then Enter again to save and quit VIM.
  11. But wait there's more!
  12. Login to your Magento Admin (using the normal localhost/magento2).
  13. Navigate to Stores > Configuration > General > Web > Url Options.
  14. Un-tick the "Use system value" checkbox and set it to NO for the "Auto-redirect to Base URL" option. Screenshot from 2021-05-09 19-37-25
  15. Click "Save Config".
  16. If Magento shows a message on the top asking to clear caches, do that. Now Ngrok instance and this Magento Module should play together to show you your website at /magento2

Special notes

  1. The first time you access your Magento site from the ngrok url after these changes it may take sometime to load all the css and scripts.
  2. If you ever get stuck in vim and want to start over, just him :q (with the colon symbol at the start) and hit enter. If that doesn't work, you can also use :q!.
  3. The steps after 10 are to prevent infinite redirect loops as mentioned in #3.

Hope this helps!