I have deployed a FastAPI backend in Azure App Service and a frontend in Azure Static Web Apps. To enhance security, I want to introduce access control so that only specific clients (in this case, my frontend) can access my backend APIs. I attempted to configure this using Access Restrictions in Azure App Service. In the Source Settings, I see options for Virtual Network or IPv4. However, I’m unable to identify the IP address block or the Virtual Network for my Azure Static Web App. Some posts say Azure static app doesn’t post a static IP address.
My goal is to set up a rule that allows only my frontend to access the backend APIs while blocking other unauthorized requests. Currently I create access control rules in my backend code (FastAPI). I think it is not that good.
app = FastAPI(
docs_url=None if os.getenv("ENV") == "production" else "/docs",
redoc_url=None if os.getenv("ENV") == "production" else "/redoc"
)
app.add_middleware(
CORSMiddleware,
allow_origins=["https://xxxx.x.azurestaticapps.net"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
ChatGPT recommends me to introduce Azure API Management. Is that feasible? What is the most effective method?



Web app Output:

