Developer Adds Time-Based Public Access to Next.js TV Dashboard Route
A developer building a SaaS project added a time-gated bypass to a Next.js middleware so that the app's /tv route remains publicly accessible between 9 am and 6 pm in the America/Cancun timezone. The TV dashboard is displayed on a lobby wall screen and was previously returning a 401 Unauthorized error after office hours due to blanket session-cookie enforcement. A pure utility function called isWithin was created in the auth library using the date-fns-tz package to accurately convert UTC server time to the correct local timezone before comparing hours. The fix required changes to both the middleware and auth files, along with unit tests mocking specific UTC timestamps to verify correct timezone behavior. The update was published on August 29, 2026, as part of the developer's Build in Public series from Playa del Carmen, México.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in