Conflict sending session in GQL products pages!
Unanswered
Japanese common catfish posted this in #help-forum
Japanese common catfishOP
Welcome,
What is the appropriate way to use user session in the products slugs static page
Currently, I call a local API to get the session and it works in
Refs:
1. https://github.com/swellstores/horizon/blob/main/pages/products/%5Bslug%5D.tsx
2. https://github.com/swellstores/horizon/blob/main/pages/products/index.tsx
What is the appropriate way to use user session in the products slugs static page
[slug].tsx with GQL? Currently, I call a local API to get the session and it works in
index.tsx and returns the Price rule in the GQL result but not on the [slug].tsx!Refs:
1. https://github.com/swellstores/horizon/blob/main/pages/products/%5Bslug%5D.tsx
2. https://github.com/swellstores/horizon/blob/main/pages/products/index.tsx
8 Replies
Hi Tarik, can you please be more precise about what's not working
you say "but not on the [slug].tsx!" ok but what doesn't work exactly ? Do you have an error ? Something you cannot implement ? What did you try and didn't work ?
Japanese common catfishOP
Thank you, Eric.
The link I sent is a Next theme for Ecommerce website, the graphQL of the store expects you to send user session in the GQL request to get additional fields on the request but that is not possible because the page is static and runs on the build. ([slug].text, no cookie exist)
To fix the issue above I created an API which returns the cookie and I send to GQL request with session included but what is confusing is in the Products page (index.tsx) the cookie returned and store API returns correct data but for products [slug].tsx the cookie is empty while all pages index.tsx and [slug].tsx are static pages! (see the repo shared)
https://github.com/swellstores/horizon/blob/main/pages/products/index.tsx
The link I sent is a Next theme for Ecommerce website, the graphQL of the store expects you to send user session in the GQL request to get additional fields on the request but that is not possible because the page is static and runs on the build. ([slug].text, no cookie exist)
To fix the issue above I created an API which returns the cookie and I send to GQL request with session included but what is confusing is in the Products page (index.tsx) the cookie returned and store API returns correct data but for products [slug].tsx the cookie is empty while all pages index.tsx and [slug].tsx are static pages! (see the repo shared)
https://github.com/swellstores/horizon/blob/main/pages/products/index.tsx
English Angora
Could you provide the .env file? It's difficult to find a solution without being able to execute the project.
Japanese common catfishOP
It is a long process, I'll see if possible to share a producible project.
You mean the cookie is not available server-side/not sent as expected ?
Japanese common catfishOP
Sent in
index.tsx but not the [slug].tsx, I mentioned the links to check the code.