Shopify, Remix, and Cloudflare have all changed a lot since I first released this template and it is no longer the recommended way to develop this kind of app. Archiving this repository.
- run
npm run dev, you will seehttp://127.0.0.1:8788in console - use ngrok to map port
8788 - create
.dev.varsfile under project root directory, fill in below content (xxx,yyy,zzzare placeholders). you may need to restart by runningnpm run dev# get SHOPIFY_APP_KEY, SHOPIFY_APP_SECRET from your shopify app overview page, the corresponding names are: Client ID, Client secret SHOPIFY_APP_KEY=xxx SHOPIFY_APP_SECRET=yyy SHOPIFY_APP_SCOPE=read_orders,read_products,read_draft_orders # do not include protocol, e.g. https APP_HOSTNAME=zzz.ngrok-free.app - go to your shopify app setup page, in
URLssection, fill in below content (zzzis a placeholder), saveApp URL:https://zzz.ngrok-free.app(protocol is needed)Allowed redirection URL(s)https://zzz.ngrok-free.app/oauth/installhttps://zzz.ngrok-free.app/oauth/callback
- go to your shopify app overview page, click
Select storeto select a store to test your app.
You should seperate your development app and production app, use production app info
You can see logs by clicking
Begin log streamunder<one specific deployment> / Functions / Real-time LogsYou can see KV variable values by clicking
ViewunderWorkers / KV / <one specific namespace>
- create a Cloudflare account if you don't have one.
- go to dashboard after verifying your email address with Cloudflare
- follow the Cloudflare Pages deployment guide, 2 things should be noticed:
- set
Build commandtonpm run build - set
Build output directorytopublic
- set
- set environment variables under
Pages / <project name> / Settings / Environment variables, you can set forproductiononly# get SHOPIFY_APP_KEY, SHOPIFY_APP_SECRET from your shopify production app overview page, the corresponding names are: Client ID, Client secret SHOPIFY_APP_KEY=xxx SHOPIFY_APP_SECRET=yyy SHOPIFY_APP_SCOPE=read_orders,read_products,read_draft_orders # do not include protocol, e.g. https, use the domain (e.g. `https://zzz.pages.dev/`, `zzz` is a placeholder) Cloudflare gives to you (you can get the link by clicking `Visit site`), you may run into `500` error when APP_HOSTNAME is not correct APP_HOSTNAME - go to your shopify production app setup page, in
URLssection, fill in below content (zzzis a placeholder), saveApp URL:https://zzz.pages.dev(protocol is needed)Allowed redirection URL(s)https://zzz.pages.dev/oauth/installhttps://zzz.pages.dev/oauth/callback
- go to your shopify production app overview page, click
Select storeto select a store to test your app. - you still will encounter errors because of KV namespace does not exist, do below:
- create a namespace
worker-SESSIONSunderWorkers / KV - Add variable in
KV namespace bindingssection underPages / <project name> / Settings / Environment variables, you can set forproductiononly- set
Variable nametoSESSIONS - select
KV namespacetoworker-SESSIONS - save
- set
- create a namespace
- Go to
All deployments, select the lastProduction, clickRetry deployment(it means re-depoly) inManage deployment