clerk/javascript

Home Page not auto-redirecting to clerk auth page on localhost in "@clerk/nextjs": "^5.0.3"

svashish305 opened this issue · 5 comments

Preliminary Checks

Reproduction

https://github.com/svashish305/sv_imaginify

Publishable key

pk_test_Y2hlZXJmdWwtY2F0LTE4LmNsZXJrLmFjY291bnRzLmRldiQ

Description

Steps to reproduce:

  1. Step 1: Run the nextjs clerk app
  2. Step 2: After following this official docs guide for my repo, navigate to localhost:3000 in chrome incognito browser.

Expected behavior:

Home page ('localhost:3000/') should auto-redirect to clerk auth page

Actual behavior:

There's no auto-redirect. If I manually navigate to localhost:3000/sign-in, I get the signin, same for signup, but there's no auto redirect setup.

Environment

System:
    OS: Windows 11 10.0.22621
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 3.44 GB / 15.81 GB
  Binaries:
    Node: 20.11.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (123.0.2420.97)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    @clerk/nextjs: ^5.0.3 => 5.0.3
    @types/node: ^20 => 20.12.7
    @types/qs: ^6.9.15 => 6.9.15
    @types/react: ^18 => 18.3.1
    @types/react-dom: ^18 => 18.3.0
    class-variance-authority: ^0.7.0 => 0.7.0    
    clsx: ^2.1.1 => 2.1.1
    eslint: ^8 => 8.57.0
    eslint-config-next: 14.2.3 => 14.2.3
    lucide-react: ^0.376.0 => 0.376.0
    next: 14.2.3 => 14.2.3
    postcss: ^8 => 8.4.38
    qs: ^6.12.1 => 6.12.1
    react: ^18 => 18.3.1
    react-dom: ^18 => 18.3.1
    tailwind-merge: ^2.3.0 => 2.3.0
    tailwindcss: ^3.4.1 => 3.4.3
    tailwindcss-animate: ^1.0.7 => 1.0.7
    typescript: ^5 => 5.4.5

Hey @svashish305 after going through the repo you attached I didn't find why the behaviour you described would be the expected one.

If am missing something, please reply with the file where this logic exists in.

Note: clerkMiddleware requires you to write the logic yourself, example:

export default clerkMiddleware((auth) => auth().protect());

@panteliselef I see
in one of the older clerk versions it was auto-redirecting from '/' to the sign-in page upon adding ClerkProvider, if this isn't expected in the latest version (5.0.3), then it makes sense to close this issue.

@panteliselef I see in one of the older clerk versions it was auto-redirecting from '/' to the sign-in page upon adding ClerkProvider, if this isn't expected in the latest version (5.0.3), then it makes sense to close this issue.

Facing the same problems. 1st time using clerk and after the basic setup it's not redirecting to the sign in page. what should I do?

@Nazmul-Hassan10 Have you tried this example from our documentation ?