Comments (15)
@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.
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.
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.
@panteliselef Thanks! It does solve the original issue, but it strangely introduces a new one:
Even though my page is defined with catch-all routes
from javascript.
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.
@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.
Is /organization
a nested route ? I couldn't tell from the screenshot above, but yes the file structure should match the path.
from javascript.
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.
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.
@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.
@panteliselef Thanks for the update. Is there a way for me to track the 2nd issue?
from javascript.
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.
@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.
@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.
@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)
- Incorrect Return Type for getAllowlistIdentifierList HOT 3
- Cannot remove divider above Privacy and Terms links in core-2 HOT 3
- Unable to Access users Property in Clerk SDK for Node.js v5.0.2 HOT 1
- `@clerk/nextjs` middleware redirection issue on login with email on chrome HOT 16
- [Node SDK]: Failed to resolve JWK during verification HOT 6
- Home Page not auto-redirecting to clerk auth page on localhost in "@clerk/nextjs": "^5.0.3" HOT 2
- `@clerk/upgrade` does not seem to work via yarn HOT 3
- Unable to add custom header when calling "isProtectedRoute". HOT 4
- forceRedirectUrl is not working when using SignInButton HOT 14
- Too many redirects on clerk.com (Dashboard AND docs) HOT 1
- React Native @clerk/clerk-expo is not working as expected HOT 20
- Sign out not working reliably in @clerk/nextjs v5 HOT 2
- [Next App Router] i18n not work on `clerkMiddleware` HOT 6
- I upgraded my app from version Expo SDK 50 to 51 and since then clerk has completely broken HOT 7
- Clerk core v2 - Clerk fails to load under cypress iframe - "Browser unauthenticated" HOT 3
- Flaky userId/sessionId on the client side after logging in
- Dependency Dashboard
- Fastify plugin doesn't run before request validation HOT 1
- Unable to disable redirect when using custom signout flow
- @clerk/remix v4.0.12 RequestInit: duplex option is required when sending a body. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from javascript.