Hosting with Heroku Sanitize shop domain error

Topic summary

A developer is encountering a server 500 error when deploying a custom Shopify app to Heroku, while the app functions correctly in local development.

Core Issue:

  • Error message: Shopify\Utils::sanitizeShopDomain(): Argument #1 ($shop) must be of type string, null given
  • The error occurs at /app/app/Lib/AuthRedirection.php on line 20
  • The shop parameter is returning null in the Heroku environment

Environment Differences:

  • Local hosting: Shop name correctly resolves to the test store name
  • Heroku hosting: Shop parameter is null, causing the sanitization function to fail

Technical Context:

  • The developer modified config variables (APP_DEBUG, LOG_LEVEL, LOG_CHANNEL) to get more detailed error information
  • Code snippet shows the redirect function attempting to sanitize the shop domain from request query parameters
  • Shopify documentation doesn’t specify adding shop name as a config variable

Status: The issue remains unresolved, with the developer seeking guidance on what might be missing programmatically in the Heroku deployment.

Summarized with AI on November 6. AI used: claude-sonnet-4-5-20250929.

Hello everyone,

I am developing a custom shopify app. It works when using local hosting but when hosting on Heroku I am getting a server 500 error. I get a little more info when I change 3 config variables (APP_DEBUG, LOG_LEVEL, and LOG_CHANNEL).

When local hosting it appears the shop is set to my test store name quickstart and #'s. The Shopify docs do not state that the shop name should be added as a config variable. Is there something I am missing programmatically?

Here is the full error: Shopify\Utils::sanitizeShopDomain(): Argument #1 ($shop) must be of type string, null given, called in /app/app/Lib/AuthRedirection.php on line 20.
The code in question is:
NOTE: I added the prints and the shop is null.

public static function redirect(Request $request, bool $isOnline = false): RedirectResponse
    {
        LogHelper::print("*****************************");
        LogHelper::print($request->query("shop"));
        $shop = Utils::sanitizeShopDomain($request->query("shop"));

        if (Context::$IS_EMBEDDED_APP && $request->query("embedded", false) === "1") {
            $redirectUrl = self::clientSideRedirectUrl($shop, $request->query());
        } else {
            $redirectUrl = self::serverSideRedirectUrl($shop, $isOnline);
        }

        return redirect($redirectUrl);
    }