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!