did not receive a shop query argument shop: undefined

Topic summary

Main issue: After creating a Shopify app (Node template via Shopify CLI) with automatically_update_urls_on_dev enabled, opening the app throws “ensureInstalledOnShop Did not receive a shop query argument shop: undefined.”

Scope/impact: Multiple developers report the same error, indicating a broader issue where the shop query parameter is missing during requests despite dev URL auto-updates.

Proposed fix: Add a custom Express middleware that sets req.query.shop from res.locals.shopify.session.shop when the query param is absent. Place it after shopify.validateAuthenticatedSession, e.g., app.use(“/api/“, shopify.validateAuthenticatedSession()); then app.use(”/”, addSessionShopToReqParams). This ensures the ‘shop’ parameter is consistently available to downstream handlers.

Status: No confirmation of success from other participants yet. The thread remains open with one concrete workaround suggested; root cause beyond missing query propagation is not fully explained.

Summarized with AI on December 20. AI used: gpt-5.

I’ve created an app using the Shopify CLI with the Node template. In the app.toml file , I set automatically_update_urls_on_dev = true, so when I start the server, the URLs update automatically. However, when I open my app, I encounter the following error: ‘ensureInstalledOnShop Did not receive a shop query argument shop: undefined.’ Could someone please help me resolve this issue?

Same problem

ensureInstalledOnShop Did not receive a shop query argument shop: undefined.’

1 Like

same here too.. :disappointed_face:

I am facing the same issue today. Can someone tell me why this is happening??

// custom middleware for shop query parameter
const addSessionShopToReqParams = (req, res, next) => {
	const shop = res.locals?.shopify?.session?.shop;
	if (shop && !req.query.shop) {
		req.query.shop = shop;
	}
	console.log("SHOP:", shop, req.query.shop);
	return next();
};

Now use the above middleware just below the validateAuthenticatedSession middelware as follows:
app.use("/api/*", shopify.validateAuthenticatedSession());
app.use("/*", addSessionShopToReqParams);