so in your case, you’d be getting the RENDER_EXTERNAL_URL (as documented at https://render.com/docs/environment-variables#all-services) and setting it as the key VITE_FRI_API_URL. That would link the preview environments together when they are created.
admin.fri.is and api.fri.is is a little bit trickier. As these don’t change, you might have to set these as environment variables on your application and use these, but then in your code detect the var IS_PULL_REQUEST and if that’s set use the value you’ve set in VITE_FRI_API_URL
I presumed that was what you were trying to do, to link backend (nodejs) and a static frontend (vuejs/vite). Certainly, React is able to use environment variables prefixed with REACT_, perhaps VITE has something similar (https://vitejs.dev/guide/env-and-mode.html)
So in your build command you can use a script, and have it do something like:
so you would still use the blueprint code to set VITE_FRI_API_URL for all environments, for your admin.fri.is it would be set to the onrender.com address, but then because IS_PULL_REQUEST would be false, it would be set it to api.fri.is
Yes, Vite has the VITE prefix, but I wasn’t sure how I could read the IS_PULL_REQUEST variable. Because I can’t do that in the client, but in a build script. That makes sens. Thanks.
But just so that I understand correctly. Lets say I set the VITE_FRI_API_URL=api.fri.is if its a pull request, that doesn’t solve if I browse to https://fri-admin.onrender.com - in that case it would talk to fri.api.is and not fri-api.onrender.com, right?
If it’s a pull request, assuming you’ve done the render.yaml as I’ve previously suggested then the API_URL would be the external address of the API.
If it’s NOT a pull request then the script would export it as api.fri.is.
It’s not at all obvious where these customer domains come into this so it’s really hard to make definitive suggestions, rather I’d suggest to experiment and see what happens,