GithubHelp home page GithubHelp logo

Comments (15)

oferitz avatar oferitz commented on May 27, 2024 1

@panteliselef Thanks a lot for the help. Yeah, sure, I can use the hash workaround for now, but please keep me updated once it's fixed

from javascript.

LekoArts avatar LekoArts commented on May 27, 2024

Hi!

Sorry to hear you're running into an issue. To help us best begin debugging the underlying cause, it is incredibly helpful if you're able to create a minimal reproduction. This is a simplified example of the issue that makes it clear and obvious what the issue is and how we can begin to debug it.

If you're up for it, we'd very much appreciate if you could provide a minimal reproduction and we'll be able to take another look.

Thanks for using Clerk!

from javascript.

panteliselef avatar panteliselef commented on May 27, 2024

Hey @oferitz thanks for reporting this. For quickly confirming if the issue has been fixed, you could add do this

<ClerkProvider clerkJSVersion="5.2.0-snapshot.vfc5e305" {...} />

from javascript.

oferitz avatar oferitz commented on May 27, 2024

@panteliselef Thanks! It does solve the original issue, but it strangely introduces a new one:
Screenshot 2024-04-30 at 14 03 16

Even though my page is defined with catch-all routes
Screenshot 2024-04-30 at 14 03 31

from javascript.

panteliselef avatar panteliselef commented on May 27, 2024

Yeah, this seems to be unrelated, we are already tracking this internally.

Do you mind doing this explicitly ?

<OrganizationProfile
   routing="path"
   path="/organization"
/>

from javascript.

oferitz avatar oferitz commented on May 27, 2024

@panteliselef Sure, do i need to change the folder structure? because doing this with the current catch-all doesn't seem to render anything on the screen.

from javascript.

panteliselef avatar panteliselef commented on May 27, 2024

Is /organization a nested route ? I couldn't tell from the screenshot above, but yes the file structure should match the path.

from javascript.

oferitz avatar oferitz commented on May 27, 2024

OK i made the necessary changes and it renders now, but the error is still present upon signout:

Error: Clerk: The "/main/organization" route is not a catch-all route. It is recommended to convert this route to a catch-all route, eg: "/main/organization/[[...rest]]/page.tsx". Alternatively, update the OrganizationProfile component to use hash-based routing by setting the "routing" prop to "hash".

from javascript.

panteliselef avatar panteliselef commented on May 27, 2024

Thanks for the information, this will help us better understand why this is happening. Seems like you are still blocked which is very unfortunate. We have prioritized this issue and we are expecting a fix soon.

Maybe for you to get unblocked you could simply use routing="hash" (with no path) for now.

from javascript.

panteliselef avatar panteliselef commented on May 27, 2024

@oferitz this got closed automatically, we are still tracking the 2nd issue you reported, but since the original one is fixed I would keep this closed.

Try updating to latest @clerk/nextjs and removing the clerkJSVersion prop.

from javascript.

oferitz avatar oferitz commented on May 27, 2024

@panteliselef Thanks for the update. Is there a way for me to track the 2nd issue?

from javascript.

nikosdouvlis avatar nikosdouvlis commented on May 27, 2024

Hello @oferitz , I'm currently on the issue and I will try to share more details once my investigation is over.
I do have a few ideas about potential edge cases that are related to the way we detect if a route is a catch-all route or not. Could you please share your middleware code?

I'm very interested to find out how you're protecting your routes as this might be connected and it will certainly help me debug :)

from javascript.

oferitz avatar oferitz commented on May 27, 2024

@nikosdouvlis Sure.

import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server'

const isMainRoute = createRouteMatcher(['/main(.*)'])

export default clerkMiddleware((auth, request) => {
  if (isMainRoute(request)) {
    auth().protect()
  }
})

export const config = {
  matcher: ['/((?!.+\\.[\\w]+$|_next).*)', '/', '/(api|trpc)(.*)']
}

from javascript.

nikosdouvlis avatar nikosdouvlis commented on May 27, 2024

@oferitz Thank you very much, this does confirm my initial findings. The problem you're hitting is caused by the auth().protect() logic in your middleware. Let me give you some context:

All Clerk components can navigate through their own pages using 3 different strategies:

  • path routing: the components will modify the path of the URL that comes after the path they are mounted. Example: if you mount your org profile on /main/organization, the component will use /main/organization as its main route but it will use /main/organization/settings to display the settings page. In this case, we need a catch-all route so the /settings part can be handled by the Clerk component. This is the default for Clerk components in Nextjs apps.
  • hash routing: this only modifies just the fragment (the part of the URL that comes after #). This does not need a catch-all route because changing the fragment does not need to trigger a NextJS navigation
  • in memory routing: mainly used by modals, does not affect the URL at all but its not bookmarkable -refreshing the page will cause the component to lose its state

When you mount a path-based Clerk component, we try to check whether you are using a catch-all route or not. The only way to do this in NextJS right now is to fire a request to a random URL under the path the component is mounted (eg /main/organization/clerk_catchall_route_check_123123) and see whether this returns a 404 or not.

In your case, a race condition after signing out triggers the error as the component incorrectly fires the catch_all_check request I described above, but this fails because auth().protect() will block the route as you are signed out.

We're sorry for the trouble! This would be very hard to debug on your own. I'm working on updating the detection logic so this false-positive cannot happen again

from javascript.

oferitz avatar oferitz commented on May 27, 2024

@nikosdouvlis Thanks for the thorough explanation. I was actually wondering how you do this check, so thanks for sharing this info. I appreciate the effort. Please keep me posted once it's fixed.

from javascript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.