Skip to content

fix: Configure API proxy with dynamic BACKEND_URL#829

Merged
Avijit-Microsoft merged 5 commits into
devfrom
rc-bug-41318
Apr 28, 2026
Merged

fix: Configure API proxy with dynamic BACKEND_URL#829
Avijit-Microsoft merged 5 commits into
devfrom
rc-bug-41318

Conversation

@Ragini-Microsoft

Copy link
Copy Markdown
Collaborator

Purpose

This pull request updates how the backend API URL for the web application is determined and injected, ensuring that the web app always connects to the correct backend container instance (ACI) endpoint based on deployment outputs instead of hardcoded or fallback values. It also improves deployment dependencies and environment variable handling for both infrastructure and application code.

Key changes:

Backend URL resolution and dependency improvements:

  • The web app's backend URL (aciBackendUrl) is now dynamically set using the actual output IP or FQDN from the container instance deployment, ensuring the web app always points to the correct backend endpoint and that the web app deployment waits for the container instance to be ready (infra/main.bicep, infra/main_custom.bicep). [1] [2]
  • Removed legacy fallback variables and logic for backend URL construction from the ARM template, further enforcing use of deployment outputs (infra/main.json). [1] [2]
  • Updated app settings injection to use the resolved backend URL from the container instance outputs, not static values (infra/main.json).

Deployment and dependency ordering:

  • Fixed and clarified resource dependency ordering in the ARM template to ensure resources like private DNS zones and the container instance are provisioned before dependent resources (infra/main.json). [1] [2]

Application code improvements:

  • The Node.js server now requires the BACKEND_URL environment variable to be set at runtime, removing any hardcoded fallback, and logs an error if it is missing. The proxy middleware is only enabled if BACKEND_URL is set (src/App/server/server.js). [1] [2] [3]

App settings merge logic:

  • In web-sites.config.bicep, the merge order for application settings was adjusted to ensure that current app settings are merged before new properties, which can affect override behavior (infra/modules/web-sites.config.bicep).

These changes together ensure that the backend URL is always accurate, deployment dependencies are respected, and the application behaves correctly in all deployment scenarios.

Does this introduce a breaking change?

  • Yes
  • No

Golden Path Validation

  • I have tested the primary workflows (the "golden path") to ensure they function correctly without errors.

Deployment Validation

  • I have validated the deployment process successfully and all services are running as expected with this change.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the web app’s backend API proxy configuration so the frontend connects to the backend container instance endpoint derived from deployment outputs rather than hardcoded/fallback values, and adjusts infra dependency/setting-merge behavior to support that.

Changes:

  • Inject BACKEND_URL into the web app using ACI IP/FQDN outputs (Bicep + generated ARM), and ensure the web app deployment depends on the ACI deployment.
  • Adjust app settings merge order so newly provided settings override existing app settings.
  • Update the Node server to only enable the /api proxy when BACKEND_URL is present (removing the hardcoded fallback).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/App/server/server.js Removes hardcoded backend fallback; conditionally enables the API proxy based on BACKEND_URL.
infra/modules/web-sites.config.bicep Changes union/merge order so new app settings override retained current settings.
infra/main.bicep Computes backend URL from containerInstance module outputs (IP/FQDN) and injects into web app settings.
infra/main_custom.bicep Computes backend URL from ACI resource properties and injects into web app settings.
infra/main.json Generated template updates: removes fallback vars, references containerInstance outputs for BACKEND_URL, and adds dependency ordering.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/App/server/server.js
Comment thread infra/main_custom.bicep Outdated
@Avijit-Microsoft Avijit-Microsoft merged commit 817791c into dev Apr 28, 2026
5 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 2.4.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@Ragini-Microsoft Ragini-Microsoft deleted the rc-bug-41318 branch May 25, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants