Based on the information provided in the extracts, you can access the path parameters in your middleware by using the request.nextUrl.pathname property. However, to extract specific parts of the pathname dynamically, you would need to use JavaScript string methods or regular expressions.
Unfortunately, the extracts do not provide a specific example of how to do this. However, you can use the split() method to split the pathname into an array of strings, and then access the specific part of the pathname that you need.
Here's a general example:
if (request.nextUrl.pathname.startsWith("/my-voyage/")) {
const parts = request.nextUrl.pathname.split('/');
const id = parts[2];
const cookie = request.cookies.get("access_token");
if (!cookie) {
return NextResponse.rewrite(
new URL(`/my-voyage/${id}/ideation`, request.url)
);
}
}
Please note that this is a general JavaScript solution and not specific to Next.js. The actual implementation may vary depending on your specific use case.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: