#Tailwind not applied on middleware redirects

8 messages · Page 1 of 1 (latest)

graceful sedge
#

Quite a basic example here. Using the with-supabase example: https://supabase.com/docs/guides/auth/auth-helpers/nextjs#automatic-configuration-recommended

Tailwind 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 /login

middleware.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?

tulip narwhalBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

hybrid hawk
#

Requests to bundled css and js are being redirected to the login page, which is why this happened

graceful sedge
#

A matcher? is that a Next or Supabase thing>

#

Ohhh

#

OK, i see what's happening now

#

perfect, thanks 😄