Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with paths #5

Open
ioan-ghisoi-cko opened this issue Jul 9, 2020 · 1 comment
Open

Not working with paths #5

ioan-ghisoi-cko opened this issue Jul 9, 2020 · 1 comment

Comments

@ioan-ghisoi-cko
Copy link

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
Copy link

Thisura98 commented May 9, 2021

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.

  1. Final result should look like this.
    Screenshot from 2021-05-09 19-30-06
  2. Hit the Escape key, then :wq, then Enter again to save and quit VIM.
  3. But wait there's more!
  4. Login to your Magento Admin (using the normal localhost/magento2).
  5. Navigate to Stores > Configuration > General > Web > Url Options.
  6. 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
  7. Click "Save Config".
  8. 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 infinite redirects #3.

Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants