Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Hi iam trying to implement consent cookies banner for hydrogen,
i have implemented everything according to tips
just getting CORS error when trying to fetch
any ideas what could this cause ? iam trying from locahost, i have elso deployed it to test env, but the cors error persist.
Thanks for any ideas !
Solved! Go to the solution
This is an accepted solution.
Problem solved with changing public checkout domain
Hi @obinecko
Please try to add a CORS header to the script that fetches the banner.
header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: GET, POST'); header("Access-Control-Allow-Headers: X-Requested-With");
But the script is loaded automaticly via <Scripts/> from shopifycloud i cannot access the source code of the script.
This is an accepted solution.
Problem solved with changing public checkout domain
Hey @obinecko
I'm stuck in the same CORS problem
My public checkout domain appears to be - myshopifydomain/checkouts/cn/AbIgHashHeReXYz
How did you configure yours?
try to check public_store_domain, does it match with yours myshopifydomain?
Hi @obinecko
In the documentation it says that I had to start the checkout in my store and copy the domain.
But it was only when I set my PUBLIC_CHECKOUT_DOMAIN to the same as PUBLIC_STORE_DOMAIN, as you said, that I managed to get the privacy banner to work..
I have the latest version of Hydrogen... did I look in the wrong documentation?
https://shopify.dev/docs/storefronts/headless/hydrogen/analytics/consent
Problem solved, thank you!
Hey @obinecko
I was able to see the cookie banner on localhost but I couldn't see it in production.
Can you help me with this too?
More info in the original post:
https://community.shopify.com/c/hydrogen-headless-and-storefront/shopify-cookie-banner-not-showing-u...
I havent doployed it to prod yet,there are changes in varaintselector, which messed up ui, hopefully ill check it this week and let you know.
but maybe check storefront env and vars, maybe there is some missmatch
Yes, problem with environment variables is most likely. Anyway, I've already checked that they are correct in the admin. Maybe I have a problem in my environment...
Let me know when you deploy.
Thanks for the reply and if you need anything just ask.