Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

811
Vistas
How to get Azure AD authentication to work in production with msal-browser in my Next.js application?

The following implementation of msal works without issues when I run it on localhost. But when I deploy it to an Azure App Service the clientId and/or tenantID seems to become undefined, even when I tried experimenting with placing the id strings directly into the file. Here is the error I get when i try to click the login button in production:

GET https://login.microsoftonline.com/undefined/v2.0/.well-known/openid-configuration 400 (Bad Request)

Uncaught (in promise) ClientAuthError: endpoints_resolution_error: Error: could not resolve endpoints. Please check network and try again. Detail: ClientAuthError: openid_config_error: Could not retrieve endpoints. Check your authority and verify the .well-known/openid-configuration endpoint returns the required endpoints. Attempted to retrieve endpoints from: https://login.microsoftonline.com/undefined/v2.0/.well-known/openid-configuration
    at t [as constructor] (_app-3866deb516d5bf6f9628.js:1)
    at new t (_app-3866deb516d5bf6f9628.js:1)
    at Function.t.createEndpointDiscoveryIncompleteError (_app-3866deb516d5bf6f9628.js:1)
    at Function.<anonymous> (_app-3866deb516d5bf6f9628.js:1)
    at _app-3866deb516d5bf6f9628.js:1
    at Object.throw (_app-3866deb516d5bf6f9628.js:1)
    at s (_app-3866deb516d5bf6f9628.js:1)

And here is the msal implementation:

import * as msal from "@azure/msal-browser";

function redirUri() {
    if (process.env.NODE_ENV == "development") {
        return "/"
    } else {
        return "https://somewebsitename.azurewebsites.net/"
    }
}

const msalConfig = {
    auth: {
        clientId: process.env.NEXT_PUBLIC_AZURE_AD_CLIENT_ID,
        authority: `https://login.microsoftonline.com/${process.env.NEXT_PUBLIC_AZURE_AD_TENANT_ID}`,
        redirectUri: redirUri()
    }
};

const msalInstance = new msal.PublicClientApplication(msalConfig);

export { msalInstance }

What is the correct way to do this?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can't get the app setting in Azure app service configuration. You can get the ClientID and tenant Id from your application configuration by doing this. process.env.clientId and process.env.tenantId

Ensure you have configured the following settings on the portal:

enter image description here

enter image description here

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda