shopify-app-template-node icon indicating copy to clipboard operation
shopify-app-template-node copied to clipboard

The page shows "No shop provided"

Open LiuYuYang01 opened this issue 1 year ago • 8 comments

Current Shopify CLI version: 3.64.1 current nodejs version is 20

English:Hello, why does the shopify-app-template-node code run without moving anything, the page shows: "No shop provided", is there a solution

LiuYuYang01 avatar Jul 28 '24 12:07 LiuYuYang01

The console prompts this:ensureInstalledOnShop did not receive a shop query argument | {shop: undefined}

LiuYuYang01 avatar Jul 28 '24 12:07 LiuYuYang01

Here is the code for shopify.js

import { BillingInterval, LATEST_API_VERSION } from "@shopify/shopify-api";
import { shopifyApp } from "@shopify/shopify-app-express";
import { SQLiteSessionStorage } from "@shopify/shopify-app-session-storage-sqlite";
import { restResources } from "@shopify/shopify-api/rest/admin/2023-04";

const DB_PATH = `${process.cwd()}/database.sqlite`;

// The transactions with Shopify will always be marked as test transactions, unless NODE_ENV is production.
// See the ensureBilling helper to learn more about billing in this template.
const billingConfig = {
  "My Shopify One-Time Charge": {
    // This is an example configuration that would do a one-time charge for $5 (only USD is currently supported)
    amount: 5.0,
    currencyCode: "USD",
    interval: BillingInterval.OneTime,
  },
};

const shopify = shopifyApp({
  api: {
    apiVersion: LATEST_API_VERSION,
    restResources,
    billing: undefined, // or replace with billingConfig above to enable example billing
  },
  auth: {
    path: "/api/auth",
    callbackPath: "/api/auth/callback",
  },
  webhooks: {
    path: "/api/webhooks",
  },
  // This should be replaced with your preferred storage strategy
  sessionStorage: new SQLiteSessionStorage(DB_PATH),
});

export default shopify;

LiuYuYang01 avatar Jul 28 '24 12:07 LiuYuYang01

Please take a look at it when you have time. Thank you very much

LiuYuYang01 avatar Jul 28 '24 12:07 LiuYuYang01

Hi @LiuYuYang01, thank you for opening this issue. Which URL did you use to open the app?

matteodepalo avatar Jul 29 '24 13:07 matteodepalo

I opened it through him, directly or in shopify: No shop provided ➜ Local: http://localhost:53384/

LiuYuYang01 avatar Jul 30 '24 08:07 LiuYuYang01

Hi @LiuYuYang01, thank you for opening this issue. Which URL did you use to open the app?

I opened it through him, directly or in shopify: No shop provided ➜ Local: http://localhost:53384/

LiuYuYang01 avatar Jul 30 '24 08:07 LiuYuYang01

@LiuYuYang01 could you try using the preview functionality of the CLI? Try pressing p after running dev.

matteodepalo avatar Jul 30 '24 15:07 matteodepalo

Hi LiuYuYang01,

This issue occurs because the shop parameter is not defined in the URL. To install the app on your Shopify store, you need to include the shop parameter in the URL.

Please use the following URL, replacing "your_shop_url" with your actual Shopify store URL:

http://localhost:53384/?shop=your_shop_url.myshopify.com

This will redirect you to the Shopify installation page, where you can complete the app installation process.

rameardo avatar Aug 05 '24 06:08 rameardo

It usually occurs when the session token is not valid. Maybe try using useAuthenticated fetch

Iweisc avatar Sep 27 '24 05:09 Iweisc