An Azure service that provides streamlined full-stack web app development.
A successful provider callback followed by {"clientPrincipal":null} means the preview URL has no valid Static Web Apps session, so first compare the same login flow on the production and PR-preview hostnames to isolate an environment-specific platform failure.
1. Isolate production versus preview
Run these tests without changing consent, role assignments, or browsers again:
- On the production default
azurestaticapps.nethostname, open:-
/.auth/login/github, then/.auth/me -
/.auth/login/aad, then/.auth/me
-
- Repeat on the exact PR URL posted by the GitHub deployment bot.
- Record the result as a matrix:
| Host | GitHub | Entra ID |
|---|---|---|
| Production default hostname | principal/null | principal/null |
| PR-preview hostname | principal/null | principal/null |
For an authenticated request, /.auth/me must return a client-principal object; null is the documented unauthenticated result.^1^ Therefore, the accepted officewerks_admin invitation cannot explain a null principal—the custom role is evaluated only after a principal exists.
Built-in GitHub and Entra ID authentication is supported on all Static Web Apps plans, including Free.^2^ Free also supports up to three preview environments, so the hosting plan itself is not an authentication exclusion.^3^
2. Validate hostname continuity
PR environments have their own temporary hostname, and custom domains do not work with preview environments.^4^ During one test, verify in the browser network trace that:
- Login starts on the PR-preview hostname.
- The callback returns to that same PR-preview hostname.
- The final page and
/.auth/merequest remain on that hostname. - No application code redirects to the production or custom domain after callback.
- The session cookie’s domain and path permit it to accompany the preview-host
/.auth/merequest.
For custom authentication, the documented callback pattern is:
https://<YOUR_SITE>/.auth/login/<PROVIDER_NAME_IN_CONFIG>/callback
For Entra ID, the provider name is aad.^5^ You are using preconfigured authentication, so do not add a custom provider merely to troubleshoot this; custom authentication requires Standard and disables the preconfigured providers.
If Azure Front Door or another reverse proxy is involved, bypass it and repeat the test directly against the preview hostname. Hostname changes through a proxy can break cookies and redirect URLs; preserving the original host is the recommended approach for Static Web Apps behind Front Door.^6^
3. Check whether the failure is platform-side
A preview-only failure affecting both GitHub and Entra ID, while production succeeds, strongly narrows the problem to the preview environment’s session/callback processing rather than provider consent or the custom role.
There is no documented general limitation stating that built-in authentication is unsupported in PR previews. However, Microsoft has previously confirmed a Static Web Apps incident where one hosted identity backend failed and a later deployment succeeded after being routed to a healthy backend.^7^
As a low-risk discriminating test:
- Push a no-op commit to the existing PR to redeploy its environment.
- Retest
/.auth/meon the same PR URL. - If practical, create a second temporary PR and test its new preview environment.
- Compare callback requests in the network traces, especially:
- callback hostname;
- HTTP status;
- any
identity.<number>.azurestaticapps.nethostname; -
Set-Cookieresponse; - UTC timestamp and request/correlation IDs.
A successful new preview while the original remains broken is useful evidence of an environment or identity-backend issue; redeployment is not a guaranteed repair.
4. Escalate with a minimal reproducible package
Since Diagnose and solve problems itself errors, include that failure rather than retrying the same detector. Open an Azure support request if available, or report the issue through the Static Web Apps GitHub repository; Microsoft lists both as support paths.^8^
Provide:
- Static Web App resource name and Azure region;
- PR number and preview hostname;
- production-versus-preview/provider result matrix;
- UTC timestamps;
- callback and
/.auth/mestatus codes; - redacted HAR showing redirects and cookie attributes;
- identity backend hostname, if shown;
- request/correlation IDs;
- confirmation that both providers fail only in preview;
- screenshot or text of the diagnostics error.
Do not include cookie values, authorization codes, access tokens, tenant identifiers, or other secrets.
References
- Accessing user information in Azure Static Web Apps
- Authenticate and authorize Static Web Apps | Microsoft Learn
- Quotas in Azure Static Web Apps
- Preview environments in Azure Static Web Apps
- Custom authentication in Azure Static Web Apps
- Using /.auth/ behind Azure Front Door - Microsoft Q&A
- We are having some issues with the built in auth for static web apps - it only affects apps deployed in the last 48 hours - Microsoft Q&A
- Azure Static Web Apps Frequently Asked Questions