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:8788
in console - use ngrok to map port
8788
- create
.dev.vars
file under project root directory, fill in below content (xxx
,yyy
,zzz
are 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
URLs
section, fill in below content (zzz
is a placeholder), saveApp URL
:https://zzz.ngrok-free.app
(protocol is needed)Allowed redirection URL(s)
https://zzz.ngrok-free.app/oauth/install
https://zzz.ngrok-free.app/oauth/callback
- go to your shopify app overview page, click
Select store
to 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 stream
under<one specific deployment> / Functions / Real-time Logs
You can see KV variable values by clicking
View
underWorkers / 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 command
tonpm run build
- set
Build output directory
topublic
- set
- set environment variables under
Pages / <project name> / Settings / Environment variables
, you can set forproduction
only# 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
URLs
section, fill in below content (zzz
is a placeholder), saveApp URL
:https://zzz.pages.dev
(protocol is needed)Allowed redirection URL(s)
https://zzz.pages.dev/oauth/install
https://zzz.pages.dev/oauth/callback
- go to your shopify production app overview page, click
Select store
to 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-SESSIONS
underWorkers / KV
- Add variable in
KV namespace bindings
section underPages / <project name> / Settings / Environment variables
, you can set forproduction
only- set
Variable name
toSESSIONS
- select
KV namespace
toworker-SESSIONS
- save
- set
- create a namespace
- Go to
All deployments
, select the lastProduction
, clickRetry deployment
(it means re-depoly) inManage deployment