Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
I am using Next.js version 13.4.15 with next-auth version 4.23. I have created an authentication middleware to protect authenticated routes with Next-Auth locally, and it works perfectly. However, when deploying in the Azure Web Static Apps environment, the middleware does nothing, allowing unauthenticated users to access the protected routes.
To Reproduce
Steps to reproduce the behavior:
Create a Next.js app using create-next-app.
Add next-auth with Azure AD as the provider.
Create the default middleware for authenticating next-auth protected routes.
Deploy the app to Azure Web Static Apps.
Note that when navigating through authenticated routes, the middleware is not activated, allowing navigation through protected routes.
Expected behavior
next-auth middleware redirects unauthenticated users trying to access a page that requires authentication.
The Problem
I am using Next.js version 13.4.15 with next-auth version 4.23. I have created an authentication middleware to protect authenticated routes with Next-Auth locally, and it works perfectly. However, when deploying in the Azure Web Static Apps environment, the middleware does nothing, allowing unauthenticated users to access the protected routes.
To Reproduce Steps to reproduce the behavior:
Expected behavior next-auth middleware redirects unauthenticated users trying to access a page that requires authentication.
Screenshots dependencies:
middleware:
next auth config:
Device info (if applicable):