Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 (not-found.tsx) triggered when logging out #3864

Closed
4 tasks done
tpiros opened this issue Aug 1, 2024 · 6 comments
Closed
4 tasks done

404 (not-found.tsx) triggered when logging out #3864

tpiros opened this issue Aug 1, 2024 · 6 comments
Labels
bug Something isn't working redirects

Comments

@tpiros
Copy link

tpiros commented Aug 1, 2024

Preliminary Checks

Reproduction

https://github.com/tpiros/clerk-sample.git

Publishable key

pk_test_Y29oZXJlbnQtcG9ueS02OC5jbGVyay5hY2NvdW50cy5kZXYk

Description

In a Next.js project, when on a protected path, after signing out, if not-found.tsx is added at the root level of the project, the 404 page shows up for a moment before the user gets redirected to the the path specified via <ClerkProvider>'s afterSignOutUrl prop.

To test, throttle the network down to Fast 3G at least to see the 404 page show up. Steps to reproduce: Sign in, Navigate to /protected, Sign out.

Environment

System:
    OS: macOS 14.5
    CPU: (8) arm64 Apple M2
    Memory: 81.64 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.15.1 - /usr/local/bin/node
    npm: 10.5.1 - ~/.npm-global/bin/npm
  Browsers:
    Chrome: 127.0.6533.74
    Chrome Canary: 129.0.6629.0
    Safari: 17.5
  npmPackages:
    @clerk/nextjs: ^5.2.8 => 5.2.8 
    @types/node: ^20 => 20.14.13 
    @types/react: ^18 => 18.3.3 
    @types/react-dom: ^18 => 18.3.0 
    daisyui: ^4.12.10 => 4.12.10 
    eslint: ^8 => 8.57.0 
    eslint-config-next: 14.2.5 => 14.2.5 
    next: 14.2.5 => 14.2.5 
    postcss: ^8 => 8.4.40 
    react: ^18 => 18.3.1 
    react-dom: ^18 => 18.3.1 
    tailwindcss: ^3.4.1 => 3.4.7 
    typescript: ^5 => 5.5.4
@tpiros tpiros added the needs-triage A ticket that needs to be triaged by a team member label Aug 1, 2024
@Sasha95
Copy link

Sasha95 commented Aug 5, 2024

same issue

@MarLapuz
Copy link

MarLapuz commented Aug 6, 2024

Extending the middleware.ts does the job for me.

export default clerkMiddleware(
  (auth, request) => {
  if (!auth().userId && !isPublicRoute(request)) {
    return auth().redirectToSignIn();
  }

  // other config here...
}

@npbee
Copy link

npbee commented Aug 7, 2024

I'm hitting something similar that I think is related to this same issue. From what I can tell, when the sign out occurs you get a POST to the route you're currently on before the redirect happens, which I think is kicked off from this server action in the ClerkProvider. Somehow this makes it here which I think is Clerk trying to force a 404.

In our case this is presenting as a 500 instead of a 404 I think because we have a custom domain on our dev environment. We get a Failed to proxy https://ourdomain.com/clerk_1723055237546 Error: connect ECONNREFUSED 127.0.0.1:443. I can reproduce this on the sample repo provided using a reverse proxy like Caddy in front of it. I'm happy to file this part as a separate issue if that's helpful!

@MisterJimson
Copy link

We are seeing this as well.

@linear linear bot added bug Something isn't working redirects and removed needs-triage A ticket that needs to be triaged by a team member labels Aug 9, 2024
@LekoArts
Copy link
Member

This should be fixed by #4001 and was released in https://github.com/clerk/javascript/blob/refs/heads/main/packages/clerk-js/CHANGELOG.md#5170.

Please remove any workaround you might have added and give it a try, you should automatically get the new version (In the network graph the request for clerk.browser.js will be for 5.17.0).

@LekoArts LekoArts closed this as completed Sep 2, 2024
@MisterJimson
Copy link

I'm seeing this again with clerk.browser.js at 5.27.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working redirects
Projects
None yet
Development

No branches or pull requests

6 participants