culturekings/shopify-app-auth-laravel

Getting the current app name based on the request

Closed this issue · 4 comments

To get the shopify configuration from the config as mentioned on the Usage, the name of the app is required to pull the configuration. What is the right way to get the app name during the execution of the request. I have a controller that is shared between 2 apps.

If you do need to do it the best way would likely be changing your route so that it passes the app name in the url. So you will have 2 routes which each app can use but only one controller so you don't have to duplicate code.

  Route::get('{app_name}/users', 'UserController@showProfile'});

Then you can use $app_name in your controller and don't have to duplicate your code.

I understand, but kinda becomes difficult when you have multiple development environments. You will have to keep separate routes for each. May have to maintain the routes in a loop so they are generated by each app if they are shared

You would use your .env file to manage your secret & key per environment and your shopify-auth config file looks at that. Routes remain the same as {app_name} points to the same app in the config file.

just noticed that shopify does give you the appName parameter as part of their query string, so I can use that.