Based on the issue description, I understand you are trying to authenticate users for your API deployed on Services App (fastapi) using Entra ID provider, but you are getting a 401 error for API requests even when the user is correctly authenticated and that you have also added a route for /* in the staticwebapp.config.json file to allow access to authenticated users.
I understand you're referring to the doc steps : Accessing user information in Azure Static Web Apps | API functions
While I'm checking on this on this further, to make sure that the browser is adding the x-ms-client-principal request header automatically when calling the API, kindly double-check these, just to isolate (if you haven't done already):
- Ensure that you are calling the API from the Static Web App using the correct URL and path.
You may check the URL and path in the Azure portal under the Static Web App's Configuration - Make sure that you have added the x-ms-client-principal request header to your API's CORS settings under CORS section.
- Review in your API's code by checking for the presence of the header in the incoming request.
Kindly let us know, I'll follow-up with you further.