Admin block extension - How can I get shop permanent_domain?

Admin block extension - How can I get shop permanent_domain?

wb1
Shopify Partner
62 2 16

For admin block extension

https://shopify.dev/docs/apps/build/admin/actions-blocks/build-admin-block?extension=react

 

Is there an easy way to access the shop handle or permanent_domain? Like foo.myshopify.com?

 

I need to make a request to my server that contains the normal shop= context that we get from embedded app requests.

 

I poked around with useApi() within BlockExtension.jsx but doesn't seem to anywhere there. There does not seem to be access to window object either.

Reply 1 (1)

Liam
Community Manager
3108 340 873

Hi - you don't need need to include the shop domain to requests to the backend through url params like that as it's not secure. The recommended approach is to use session tokens. Session tokens are automatically included when they make a fetch request to your app's urlSpecifically the shop domain is available as the dest property after decoding the session token (either using one of Shopify's libraries or manually decoding with a JWT library). 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog