You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The NestJS api application is proxied via NX proxies to /api. The api application also contains
a global prefix to /api.
Because we use NX proxies, we basically disable the usage of NextJS API requests in the pages/api folder because the requests are always proxied to the backend.
This application uses Mikro-ORM for it's database. When performing offline auth, the authenticated shop gets inserted into the shops table with an offline token. This token can then be used for webhook/background operations.
Setup
Install dependencies
npm install
Copy the example environment variables and fill in yours:
Visit https://<HOST>/?shop=<SHOP> to start the OAuth installation procedure of your app.
Authentication with Shopify
The application allows for both Online and Offline authentication. But Shopify recommends using
offline auth for only installing your application, and online auth for loading data in your frontend.
The ProductsController in this application that returns the total product count in Shopify, utilizes @ShopifyOnlineAuth() decorator. That signals our application to look for online JWT tokens when calling the GET /api/products/count route.
The frontend utilizes @shopify/app-bridge to transparently fetch online tokens for us using the userLoggedInfetch helper function.
About
Example monorepo app with @nest-shopify/nest-shopify using NestJS backend and NextJS frontend