I have PR environments enabled. When I access RENDER_EXTERNAL_URL, however, it contains the URL of the “parent” deployment, not the URL of the PR deployment. Is there any way I can get the URL for the PR deployment?
I’ve checked this on my own service and the value is that of the Pull request preview that was created - what was the service type you experienced this on?
Ok, I’ve just tested with a static site to be double sure that displays process.env.REACT_APP_RENDER_EXTERNAL_URL and has a build command of REACT_APP_RENDER_EXTERNAL_URL=$RENDER_EXTERNAL_URL yarn build and it shows me what I’d expect. Let me know how you get on.
I believe my problem is a result of a NextJS nuance where environment variables without NEXT_PUBLIC_ prefix are not exposed to the browser (Basic Features: Environment Variables | Next.js). I have verified that RENDER_EXTERNAL_URL and RENDER_EXTERNAL_HOST are both undefined in my app. I’m on a quest now to try to figure out a NextJS solution to the problem.
@John_B I believe I have found a NextJS solution. In the render Environment Variables page, I set a variable such as NEXT_PUBLIC_URL to $RENDER_EXTERNAL_URL. Then in my app I am able to reference NEXT_PUBLIC_URL successfully. Again this is a specific nuance in NextJS for static sites. Thanks for your help!