#skip sub-path in link component
29 messages · Page 1 of 1 (latest)
🔎 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)
the only thing that I know is, that you can repeat the last section of the url and then add a new one.
So if you are on
https://localhost:3000/hello/world/main
And you link to
world/second
You will be redirect to
https://localhost:3000/hello/world/second
Without rewriting hello again.
normally your middleware handles the path for the internationalization 🤔
and to get the locale i would need to be in a server component because it needs to be awaited so i can then use the locale in the link
yes, it does
my issue is with normal links
when the path was before:
localhost:3000/dashboard
it doesnt work anymore but should be:
localhost:3000/(locale)/dashboard
Can’t you use useParams() to get it in client components?
So with internationalization it would look like this:
So if you are on
https://localhost:3000/en/world/main
And you link to
world/second
You will be redirect to
https://localhost:3000/en/world/second
Without rewriting en again.
Or if you need to provide a path beginning with / you can do it like that:
https://localhost:3000/en/world/main
And you link to
/world/second
You will be redirect to
https://localhost:3000/world/second
Your middleware will catch, that there is no internationalization in it and redirect to
https://localhost:3000/en/world/second
sounds like a great idea, letme try it real quick
i will test it again in a second
okay so that worked! Thanks for that
but i will have a look in my middleware tho
Because its quite tedious to do useParams in every file i want to use a link component
yea, joulev's way is a fast way. The way I mentioned is an effective way
do you know how i can default export these 2? because i need the auth and the intl:
import { authMiddleware } from "@clerk/nextjs"
import createMiddleware from "next-intl/middleware"
export default authMiddleware({
// Allow signed out users to access the specified routes:
publicRoutes: ["/", "/api/getCollabToken/[userId]"],
ignoredRoutes: ["/tutorial/(.*)", "/api"],
})
export default createMiddleware({
// A list of all locales that are supported
locales: ["en", "de"],
// Used when no locale matches
defaultLocale: "en",
})
export const config = {
// Match only internationalized pathnames
matcher: [
"/((?!.+\\.[\\w]+$|_next).*)",
"/(api|trpc)(.*)",
"/",
"/(de|en)/:path*",
],
}
(before i removed the export default from the authMiddleware but then this error came:)
Unable to find `next-intl` locale because the middleware didn't run on this request. See https://next-intl-docs.vercel.app/docs/routing/middleware#unable-to-find-locale. The `notFound()` function will be called as a result.
I am not into clerk middleware, sorry. If you know how to check for public and dingoredRoutes inside a normal middleware, you can directly add the internationalization part to it. Like that you merged both actions in one middelware
Still thanks a Lot tho ❤️
happy to help. Please mark solution
Doesnt Work on Phone 😭
If you hold your finger on the message you still get the „Apps“
Yep but then it says no commands available
lol @snow rock would you mark the correct message?
I already refreshed the app
This question has been marked as answered! If you have any other questions, feel free to create another post
[Click here](#1245463111587336262 message)