I am using shopify_app gem with rails 5. I want the shopify_app to work from a nested route. For eg: /shopify_app/login or '/shopify_app/auth/shopify/callback'.
I tried the solution given in gem documentation and put these lines in my routes.rb file:
mount ShopifyApp::Engine, at: 'shopify_app'
get '/shopify_app' => 'settings#index'
But it didn't work this way. So I googled around and found a solution to make it work by doing some changes in an omniauth initializer.
Rails.application.config.middleware.use OmniAuth::Builder do
provider :shopify, ShopifyApp.configuration.api_key, ShopifyApp.configuration.secret, scope: ShopifyApp.configuration.scope, callback_path: '/shopify_app/auth/shopify/callback'
end
Here are the app settings:
Embedded App SDK: enabled
App Url: https://salebait.com/settings
Whitelisted Redirection Url: https://salebait.com/shopify_app/auth/shopify/callback
Now the problem is when I install my app for the first time it redirects to my website's homepage (https://salebait.com) after installation but it should open https://salebait.com/settings page in store admin instead. And if I close the browser or logout from the store and come back again to the app it goes to https://salebait.com/login which is not a valid page since all app routes are wrapped inside /shopify_app/ so the login URL for the app should be https://salebait.com/shopify_app/login. Then I have to manually hit the app's login URL to make it work.
Please suggest some solution make my app routes work smoothly.
Edit: App redirects to wrong login page if try to open app in another browser.. Here is the error screen for that:
Thanks.