Skip to main content

Posts

Showing posts with the label Architecture

Strangler Fig Strategy: Sharing Auth Cookies Between Legacy ASP.NET and Next.js

  The Hook: The "Unauthenticated" Glitch You are migrating a monolithic ASP.NET application to Next.js using the Strangler Fig pattern. You have set up a reverse proxy (YARP, Nginx, or CloudFront) to route  /app  to Next.js and everything else to the legacy backend. The user logs in via the legacy ASP.NET login form. They are redirected to the homepage successfully. Then, they click a link pointing to the new Next.js dashboard. Result:  They are immediately redirected back to the login page. Despite the browser sending the  .AspNetCore.Cookies  (or  .ASPXAUTH ) cookie with every request, Next.js treats the user as a stranger. You effectively have two isolated silos sharing a domain but failing to share state. The Root Cause: Incompatible Cryptography The issue is not network routing; it is cryptographic serialization. Serialization:  When a user logs in, ASP.NET creates an  AuthenticationTicket . It serializes this .NET object into binary. En...

Strangler Fig Pattern: Sharing Auth Sessions Between Legacy PHP and Next.js

  The Strangler Fig pattern is the de facto standard for migrating legacy monoliths, but it hits a concrete wall immediately: Authentication. You have a legacy PHP application (Laravel, Symfony, or vanilla) serving the root domain. You deploy a Next.js App Router instance to handle specific routes (e.g.,  /dashboard/analytics ). You configure your load balancer (Nginx/AWS ALB) to route traffic correctly. The browser sends the  PHPSESSID  (or  laravel_session ) cookie to the Next.js server. However, your Next.js application treats the user as unauthenticated. The Root Cause: Serialization Incompatibility The issue is not network reachability or cookie scope. If both apps sit on  example.com , the browser transmits the cookies to both backends. The failure occurs at the  deserialization layer . Storage Format:  PHP sessions are typically stored on the file system ( /var/lib/php/sessions ) or Redis. PHP uses a proprietary serialization format (e.g.,...