According to the documentation of Static Web App (SWA), you can create an Azure Function that will allow to assign an authenticated User custom roles, usually called GetRoles: SWA custom auth. The problem is that I am not able to get this functionality to work - even though I added the function it does not get triggered and I can not assign custom roles to the User.
I have used SWA cli to debug locally with the provided authentication emulator, but when I get logged in, it does not trigger the GetRoles function, so I can not debug code that I am suppose to write. I have run the function in a separate terminal (to be able to attach in vsc) and started the SWA with: swa start ./my-dist --api-devserver-url http://localhost:7071.
I have also tried to deploy to Azure to see, if maybe there it will call GetRoles automatically, but that also did not work (Roles were still authenticated and anonymous).Here additional question appeared - how to see logs from the provided api function that was included in the SWA? It would have to be an dedicated Azure Function that was deployed separately (bring your own custom function)?
I have followed this example provided on GH: https://github.com/staticwebdev/roles-function, and just changed the function to return an array of some custom roles: ["admin", "reader"], so I have expected that now, after login, the roles would be: admin, reader, but it remains: authenticated, anonymous. What am I doing wrong here?