Have your say in Community Polls: What was/is your greatest motivation to start your own business?

did not receive a shop query argument shop: undefined

did not receive a shop query argument shop: undefined

developer4
Shopify Partner
5 0 0

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?

Replies 4 (4)

Sikendar
Shopify Partner
2 0 1

Same problem 

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

leonpl
Shopify Partner
13 0 3

same here too.. 😞

thenakulgupta
Shopify Partner
1 0 0

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

Tahidul_Islam
Shopify Partner
3 0 0
// 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);