Ah, in this example I see no reference to pullRequestPreviewsEnabled: true – maybe I need to remove that? If so, that should probably be mentioned explicitly in the docs for Preview Environments (and/or throw an error).
I’m trying to work around this like so in my webpack config file (craco in this case):
if (process.env.IS_PULL_REQUEST) {
process.env.BACKEND_URL = process.env.RENDER_EXTERNAL_URL.replace(
"-frontend-",
"-backend-"
);
}
so that I can get this URL: https://staging-mycompany-backend-pr-123.onrender.com/
from this URL: https://staging-mycompany-frontend-pr-123.onrender.com/
Yeah, sorry, that’s what we had – edited to reflect. The BACKEND_HOST env var did appear, but it pointed to the general staging environment, not the one specific to the PR (ie, the env var was missing -pr-123)
I wouldn’t expect you to to see -pr-123 in the env vars. From this page Render · The Easiest Cloud For All Your Apps, you should see the environment created for your PR listed - going into one of the PR’s will show the services that were created and I would expect that the BACKEND_HOST env var on your webservice be set to the set to the host name of your backend service that we created. If you open a support ticket and detail the service names we can dig further, support@render.com
It’s a point of confusion and one I had myself when I first found Render - between Pull Request Previews and Preview Environments. Our Pull request preview feature creates an instance of the service in question whereas Preview Environments enabled with previewsEnabled will create an entire environment for the PR which typically include web/db etc etc
Right, that’s what I thought. It sounds like exactly what I want. But how am I supposed to connect these preview services to each other? How does service A know the hostname of service B?
it’s setting a variable named BACKEND_HOST and it’s value is coming from the service named backend and it’s using the ‘host’ property that is available.
RENDER_EXTERNAL_URL no longer seems to be accepted - I can only seem to get ahold of the internal addresses via the vars listed in the docs.
I am trying to build a static site with the external hostname of a web service injected at build time - instead my browser ends up trying to connect via the internal hostnames.