Same issue here. I tried checking typeof on process - it’s not treating it like a regular variable - it’s just hard crashing if process is in there at all.
I think something changed with how the replacement works. It used to work to do things like typeof process, but now it doesn’t.
You have to type the string exactly like process.env.APP_URL and that will get converted to your localhost URL when you build the extensions. I think you just have to use a try catch for production.
During shopify app dev, Node.js is running, so process.env is available, and the CLI automatically injects the local app URL.
However, after deployment, the Checkout UI Extension no longer runs in a Node.js environment, so process.env does not exist.
For now, I’m manually switching the app URL like this
//const APP_URL = "https://my-app-name.fly.dev"; // Production
const APP_URL: string = `${process.env.APP_URL}`; // Development
const fetchUrl: string = `${APP_URL}/api/payment-terms`;
This is not an ideal solution. If anyone knows a better way to automatically switch the app URL based on the environment, I’d really appreciate it if you could share it