Call Shopify Storefront API using public or private access token from Nextjs server action?

Call Shopify Storefront API using public or private access token from Nextjs server action?

sorin_12
Visitor
3 0 0

I am building a custom storefront using Next.JS V.14.1.3 for my Shopify shop. I am using as an example the Next.JS Commerce template v 2.0. Reading the Shopify docs and discussions, I am confused. I have a custom fetch function that should query for all my products in Shopify. This fetch function is called from a server component. Using my storefront public access token everything works perfectly but my understanding is that public access token should be used in queries made from the client components not the server. So I switched my fetch header to use the Storefront Private Access token, but then I read in the docs that I should also pass the Shopify-Storefront-Buyer-IP header so my requests won't get throttled. 

1. I don't understand how I should pass this header since I am on the server;

2. Is it ok to use the X-Shopify-Storefront-Access-Token with the public access token value when making fetch call for products from a server component or server action? (Will Shopify know not to throttle API requests since I am not calling the Storefront API from browser directly and not passing any Shopify-Storefront-Buyer-IP address);

Replies 0 (0)