Azure Static Web Apps has built-in Authentication and Authorization for both the web and API part of the application.
At the end of last year, I wrote about a package to make it easier in React apps to work with auth and get access to the user details. But this still left a gap in the APIs, your APIs need to parse the JSON out of a custom header, which is base64 encoded. All a bit complicated in my book.
So, I decided to make another package to help with that,
Using the package
The package exposes two functions,
getUserInfo. Here’s an example of an API that uses the package:
isAuthenticated function takes the request that the API receives and returns a boolean of whether the user is authenticated or not, and the
Hopefully this makes it just that bit easier to work with authenticated experiences on Static Web Apps.