Search code examples
azure-web-app-serviceopenid-connectblazor-webassembly

How can I use OIDC through a custom URL in Blazor Webassembly published on Azure App Service


I'm trying to deploy a Blazor WASM solution using both local, Google and Microsoft signin, but am having trouble when using a custom URL.

I've deployed to Azure App Service, and following previous threads, have got it working through the URL MySite.azurewebsites.net by ammending the service-worker.published.js to:

async function onFetch(event) {
    let cachedResponse = null;
    if (event.request.method === 'GET') {
        // For all navigation requests, try to serve index.html from cache
        // If you need some URLs to be server-rendered, edit the following check to exclude those URLs
        const shouldServeIndexHtml = event.request.mode === 'navigate'
            && !event.request.url.includes('/connect/')
            && !event.request.url.includes('/signin-google')
            && !event.request.url.includes('/Identity/');

        const request = shouldServeIndexHtml ? 'index.html' : event.request;
        const cache = await caches.open(cacheName);
        cachedResponse = await cache.match(request);
    }

    return cachedResponse || fetch(event.request);
}

My problem now is that I've added a custom https domain of MySite.co.uk, the site still works fine when I go to MySite.azurewebsites.net, but when I go to MySite.co.uk it sends me to the "Sorry, there's nothing at this address" page.

Any suggestions of how to get this all wired up to allow use of the custom domain? Thanks!


Solution

  • Looks like it was something to do with the javascript libraries used on the login page. Once I resolved all of the errors in the javascript console, it started working, so not sure exactly which one fixed it.