I’m facing a 403 Forbidden error when my Next.js frontend application (using NextAuth) calls Azure AD B2C, even though all authentication configurations appear to be correct.
Application Setup
Authentication: NextAuth.js
Identity Provider: Azure AD B2C
Hosting: Azure App Service
App Service Plan: Premium V2
Azure AD B2C Configuration
Client ID and Client Secret are verified and correct
Redirect URIs are correctly configured in Azure AD B2C
NextAuth provider configuration matches B2C settings
App Service Configuration
App Service is VNet integrated
A NAT Gateway is attached to the subnet to address possible SNAT/IP exhaustion
Minimum App Service instance count increased to 2
App Settings configured:
NEXTAUTH_URL
`NEXTAUTH_SECRET`
Problem
When the Next.js application initiates authentication, the request to Azure AD B2C fails with:
HTTP Status: 403 Forbidden
The issue occurs only after VNet integration
Authentication works correctly when running locally
What I’ve Already Checked
Client ID / Secret correctness
Redirect URI matching exactly (including protocol and path)
NextAuth environment variables present in App Service
SNAT/IP exhaustion mitigations via NAT Gateway and scaling
No errors reported in App Service logs beyond the 403
Question
Can Azure AD B2C block requests originating from VNet-integrated App Services due to outbound IP changes or network routing?
Are there additional outbound firewall, service endpoint, or NSG considerations when App Service with NextAuth communicates with Azure AD B2C?
Is there any Azure AD B2C setting or known limitation related to App Service VNet integration or NAT Gateway usage?
Are there recommended diagnostic logs or headers to inspect on the B2C side to identify the root cause of the 403?
Any guidance on troubleshooting this scenario or known best practices would be greatly appreciated.
Environment Summary
Azure App Service (Premium V2)
VNet Integration + NAT Gateway
Next.js + NextAuth
Azure AD B2C
Thank you.I’m facing a 403 Forbidden error when my Next.js frontend application (using NextAuth) calls Azure AD B2C, even though all authentication configurations appear to be correct.
Application Setup
Frontend: Next.js
Authentication: NextAuth.js
Identity Provider: Azure AD B2C
Hosting: Azure App Service
App Service Plan: Premium V2
Azure AD B2C Configuration
Client ID and Client Secret are verified and correct
Redirect URIs are correctly configured in Azure AD B2C
NextAuth provider configuration matches B2C settings
App Service Configuration
App Service is VNet integrated
A NAT Gateway is attached to the subnet to address possible SNAT/IP exhaustion
Minimum App Service instance count increased to 2
App Settings configured:
NEXTAUTH_URL
`NEXTAUTH_SECRET`
Problem
When the Next.js application initiates authentication, the request to Azure AD B2C fails with:
HTTP Status: 403 Forbidden
The issue occurs only after VNet integration
Authentication works correctly when running locally
What I’ve Already Checked
Client ID / Secret correctness
Redirect URI matching exactly (including protocol and path)
NextAuth environment variables present in App Service
SNAT/IP exhaustion mitigations via NAT Gateway and scaling
No errors reported in App Service logs beyond the 403
Question
Can Azure AD B2C block requests originating from VNet-integrated App Services due to outbound IP changes or network routing?
Are there additional outbound firewall, service endpoint, or NSG considerations when App Service with NextAuth communicates with Azure AD B2C?
Is there any Azure AD B2C setting or known limitation related to App Service VNet integration or NAT Gateway usage?
Are there recommended diagnostic logs or headers to inspect on the B2C side to identify the root cause of the 403?
Any guidance on troubleshooting this scenario or known best practices would be greatly appreciated.
Environment Summary
Azure App Service (Premium V2)
VNet Integration + NAT Gateway
Next.js + NextAuth
Azure AD B2C
Facing this issue from last 15 days. The application is working as expected from last 1 year.
Thank you.