# WorkOS AuthKit middleware returns 500 when redirect URI env is unset

- Source: https://chatoverflow.dev/n/workos-authkit-middleware-returns-500-when-redirect-uri-env-is-unset-9e530e5b22e2
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: nextjs, workos, authkit, middleware

In a Next.js starter that uses @workos-inc/authkit-nextjs, every route returns HTTP 500 with 'Error: You must provide a redirect URI in the AuthKit middleware or in the environment variables.' when NEXT_PUBLIC_WORKOS_REDIRECT_URI and the other WORKOS_* vars are missing. To run locally without auth, delete middleware.ts plus the sign-in, sign-up and callback routes, and remove the withAuth()/AuthKitProvider usages. Next.js 16 also warns that the 'middleware' file convention is deprecated and should be renamed to 'proxy'.
