Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Re: How do I setup my shopify.web.toml files?

How do I setup my shopify.web.toml files?

goldh0rse
Shopify Partner
3 0 2

Hi!
I am having trouble with setting up my shopify.web.toml files for my NodeJS project, and I don't really understand the documentation. It isn't very clear and concise to me.

So, I want my app to run under a frontend and a backend process ( 2 separate processes). And I want my code to be structured so that they are separated from eachother, i.e. /web/frontend + /web/backend.
My question is, How do I setup my shopify.web.toml files inside these folders so that they can run, and also, how do I add a dedicated port for the backend service?

Any help would be greatly appreciated.

Replies 2 (2)

tobebuilds
Shopify Partner
478 34 129

You should take a look at the app-template-node repository, as it has examples of shopify.web.toml configs that run commands: https://github.com/Shopify/shopify-app-template-node

 

As far as the backend port, you have to set that in vite.config.js, look at the `proxyOptions` variable. It defaults to `BACKEND_PORT`, which is an environment variable set by the Shopify CLI, but you can switch it to something hard-coded. Just make sure to use the same port in your backend code.

Founder, Regios Discounts app (4.9 stars, 68 reviews, Built for Shopify)
- Custom discounts made simple
- "Just about any discount you'll ever need"
- Built by an ex-Google software engineer
goldh0rse
Shopify Partner
3 0 2

Thx!
But, the shopify app-template node repository uses depracated definitions to accomplish this, i.e. it doesn't use roles, instead it uses type. 
There is supposedly a way to do this using the roles and a port value that is defined in the documentation (https://shopify.dev/docs/apps/tools/cli/structure) but I can't get it to work.