Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Backend URL in POS UI Extensions

Backend URL in POS UI Extensions

dpavlutin
Shopify Partner
14 1 2

Hello everyone!

 

I'm developing a POS UI Extension that communicates with my Backend server. The only documentation about using a Backend in POS UI extension I found here.

 

During development mode, `shopify app dev` using Cloudflare creates my app URL dynamically. Thus each time the Backend URL is different.

 

How can I access in my POS UI Extension the dynamic URL? Normally I would read `process.env.HOST` (which is set during dev mode), but `process.env` is not available inside POS UI extension.

 

Screenshot 2023-09-02 at 13.17.31.png

 

Thanks!

Boxi: Build a Box & Gift Boxes - increase sales and AOV by letting your customers build personalized product boxes.
ISBNExpress: Books Importer - import book details by ISBN into your bookstore with a single click.
Shopify Guides for Merchants
Replies 2 (2)

dsn
Shopify Partner
8 0 5

Hello,

 

I'm facing same issue. By now, I created a pseudo env file in extensions root in which I define the host url. The file is included in .gitignore so there is no risk to upload it by accident.

 

Within the pseudoenv file, a constant is exported with the url as a string. This constant is imported in the extensions where the fetch url composition is done.

 

I know this is far from being the ideal solution, but this way I just have to update the host one time to keep all my extensions connected to the backend. Just have to remember to modify the host to the production one when deploying the extensions.

 

dsn_0-1693857260570.pngdsn_1-1693857279979.pngdsn_2-1693857328963.png

Hope this help until we got a final solution from Shopify.

dpavlutin
Shopify Partner
14 1 2

Thanks @dsn ! That's my current approach too. I also dynamically update the pseudo config file with the changing app URL during dev mode.

Seems like that's the workaround until we got a solution from Shopify.

Boxi: Build a Box & Gift Boxes - increase sales and AOV by letting your customers build personalized product boxes.
ISBNExpress: Books Importer - import book details by ISBN into your bookstore with a single click.
Shopify Guides for Merchants