The Gravity that Keeps Startups from Flying Off Course

Growth in a startup is usually exiting it’s tempting to pour everything into product, speed and market traction. I know. I’ve lived it. At Auto Audit Group which houses 3 companies we’re racing forward with alot of interensing technologies in the automotive space. The urgency is real. But what I’ve learned through my past expereinces …

Continue reading The Gravity that Keeps Startups from Flying Off Course

From Login Loops to Seamless Auth: Lessons from Migrating to Azure AD & MSAL in Next.js

Over the past 24 hours, I tackled a series of authentication and UI challenges while migrating a Next.js app to use Azure AD authentication via MSAL.js. The process was a deep dive into React, Next.js App Router, and the intricacies of modern authentication. Here’s a recap of the issues, solutions, and key takeaways. The Challenge: Modernizing Authentication The goal was to fully migrate from a custom JWT-based authentication system to Azure AD using MSAL.js, ensuring that all API calls used MSAL tokens and that the user experience was seamless across login, logout, and protected routes. Along the way, I also wanted to modernize the app’s layout using shadcn/ui components and improve the sidebar and header for better usability. …

Continue reading From Login Loops to Seamless Auth: Lessons from Migrating to Azure AD & MSAL in Next.js

The Rules of Hooks and Authentication State

Recently, I ran into a persistent login loop while integrating Azure AD authentication with MSAL.js in a Next.js app. Even after correctly hydrating the MSAL account and setting the user state, my app kept redirecting back to the login page. Debugging revealed that the authentication state was being set, but the UI didn’t reflect it as expected. The Culprit: Breaking the Rules of Hooks After some investigation, I discovered the root cause: a violation of React’s Rules of Hooks. In my login page, I was returning early from the component (for …

Continue reading The Rules of Hooks and Authentication State

Debugging Azure AD Authentication in a Next.js/Prisma App

Over the past two days, I dove deep into debugging a persistent authentication issue in my Next.js app, which uses Azure AD for login and Prisma for database management. Here’s a recap of the process, the roadblocks, and the lessons learned. The Problem Every time I tried to access /api/auth/me, I was met with a frustrating 401 Unauthorized error. The frontend was using MSAL to acquire tokens, but the backend refused to recognize them. The error persisted despite having all the right environment variables and a seemingly correct setup. The Debugging Process 1. Verifying the Frontend Checked MSAL Account Detection: Added console logs to ensure MSAL was detecting the user and acquiring tokens. Inspected Network Requests: Used browser …

Continue reading Debugging Azure AD Authentication in a Next.js/Prisma App

How I Fixed a 401 Unauthorized Error with Azure AD and Next.js API Routes

Recently, while building a Next.js app with Azure AD authentication, I ran into a persistent 401 Unauthorized error on my /api/auth/me endpoint. The fix turned out to be a subtle but important detail about environment variables in Next.js. Here’s how I diagnosed and resolved the issue. The Problem After setting up Azure AD authentication, my frontend could log in and acquire tokens, but every call to /api/auth/me returned: HTTP/1.1 401 Unauthorized {"error":"Invalid or expired token","details":"unexpected \"iss\" claim value"} I checked the token in jwt.ms and saw the iss (issuer) claim …

Continue reading How I Fixed a 401 Unauthorized Error with Azure AD and Next.js API Routes

Installing & Running UniFi Controller in Docker on a Raspberry Pi & Adopting the U6 Lite

Over the past few MONTHS, I decided to take on a fun but slightly finicky project: setting up a self-hosted UniFi Network Controller on a Raspberry Pi using Docker, and adopting a UniFi U6 Lite access point into my local network. It wasn’t entirely smooth sailing but that’s what makes it worth writing about. The …

Continue reading Installing & Running UniFi Controller in Docker on a Raspberry Pi & Adopting the U6 Lite

A Declaration of the Independence of Cyberspace: Empowering Sub-Saharan Africa in the Modern Internet Era

The digital revolution in Sub-Saharan Africa has illuminated the relevance of John Perry Barlow's "A Declaration of the Independence of Cyberspace." As I witness the growth of internet connectivity in the region, I am reminded of the vision of an independent cyberspace, where individuals can freely express themselves, access information, and contribute to the digital realm.