Questions and discussions about using the Shopify CLI and Shopify-built libraries.
I'm having a pickle of a time getting access (pun intended) to user session accessTokens in the GetServerSideProps function so as to prepopulate props with page data on page load.
I am able to use the server's own offline access token for api calls to work, however I cannot access the logged-in app's scope and use
const session = await getSessionToken(app);
console.log("current session: ", session);
inside the GetServerSideProps function.
What am I missing?
I'm assuming this is a desired design pattern, rather than making all app queries after page load with session token.
Best,
rustcity
Hmm. K, so because the GetServerSideProps is running on the backend, its' neccessary to pull the session info off the koa context:
const { req, res } = ctx;
const sessionRetrieved = await Shopify.Utils.loadCurrentSession(
req,
res
);
Hello @rustcity I am also facing same problem. I also want to make req using getserversideprop, but not able to find any solution. If you found solution can you please share with me.
Thanks