Hello, Welcome to MS Q&A
The issue you are facing with the Static Web Apps (SWA) frontend receiving a 401 Unauthorized response when trying to connect to the backend Function App. Let's troubleshoot this:
- Ensure that the account making the requests has the necessary Static Web App role matching what's specified in the staticwebapp.database.config.json file. The user must have the correct role to perform operations on the endpoint.
- Check if the request includes a header with a key of
X-MS-API-ROLE
and a value that matches a role name specified in your entity configuration rules. Role name matching is case-sensitive.
- Verify that the StaticWebAppsAuthCookie is being properly handled and authenticated in the backend Function App. This cookie should authorize the frontend to access the backend. If the above steps do not resolve the issue, you may need to further investigate the configuration and permissions set up between the SWA frontend and the backend Function App. It's important to ensure that the authentication provider on the Function App is correctly configured to accept requests from the SWA frontend.
If you continue to face issues with the requests being blocked at the function app level, you can post an issue or question on the DAB GitHub forum for further assistance. I hope this helps address your concerns regarding the 401 Unauthorized response and the Function App not being run. If you need additional support, feel free to reach out for further guidance.
For more detailed instructions, you can view solution:
Please let me know if any questions
Kindly accept answer if it helps
Thanks
Deepanshu