Hi everyone,
I’m encountering an error with
@shopify/shopify-app-express
(v5.0.8) in my Node.js app. My server is crashing/logging an error when
ensureInstalledOnShop()
is called.
The Error:
[shopify-app/ERROR] ensureInstalledOnShop did not receive a shop query argument | {shop: undefined}
This happens in my
index.jsmiddleware setup where I’m handling frontend rendering. It seems like the request reaching this middleware is missing the
shop
query parameter, even though I’m expecting Shopify to pass it.
Code Snippet (
web/index.js):
javascript
app.use(“*”, async (req, res, next) => {
// Skip Shopify install check for API routes
if (req.path.startsWith(“/api”)) {
return next();
}
// Only allow GET requests for frontend rendering
if (req.method !== “GET”) {
return next();
}
// Error occurs here
return shopify.ensureInstalledOnShop()(req, res, async () => {
return res
.status(200)
.set(“Content-Type”, “text/html”)
.send(
readFileSync(join(STATIC_PATH, “index.html”))
.toString()
.replace(“%VITE_SHOPIFY_API_KEY%”, process.env.SHOPIFY_API_KEY || “”)
);
});
});
Steps to Reproduce:
-
Run
npm run dev -
App starts successfully.
-
The error appears in the terminal when I try to open the app (or when a restart happens).
Has anyone faced this issue where the
shop
argument is undefined at this stage? Any advice on how to handle cases where the query param might be missing?
Thanks in advance!