Tailwind not applied on middleware redirects
Answered
American Sable posted this in #help-forum
American SableOP
Quite a basic example here. Using the
Tailwind on
However, in the middleware, if you add some logic to redirect the user, then tailwind is no longer applied to the styling of
middleware.ts
If I check browser logs, with this middleware codeblock inserted, I can see
however if i remove it, there are no browser errors and tailwind loads
Any idea why this might be?
with-supabase example: https://supabase.com/docs/guides/auth/auth-helpers/nextjs#automatic-configuration-recommendedTailwind on
/login is applied correctly if you use this example as is, or navigate to that page directly.However, in the middleware, if you add some logic to redirect the user, then tailwind is no longer applied to the styling of
/loginmiddleware.ts
if (!user && req.nextUrl.pathname !== '/login') {
return NextResponse.redirect(new URL('/login', req.url))
}If I check browser logs, with this middleware codeblock inserted, I can see
main-app.js?v=1692001396459:1 Uncaught SyntaxError: Unexpected token '<' (at main-app.js?v=1692001396459:1:1)
webpack.js?v=1692001396459:1 Uncaught SyntaxError: Unexpected token '<' (at webpack.js?v=1692001396459:1:1)however if i remove it, there are no browser errors and tailwind loads
Any idea why this might be?
6 Replies
Requests to bundled css and js are being redirected to the login page, which is why this happened
American SableOP
A matcher? is that a Next or Supabase thing>
Ohhh
OK, i see what's happening now
perfect, thanks 😄