How can i make Next js Dynamic Route public in clerk.js

732 views Asked by At

I trying to make nextjs dynamic route public

export default authMiddleware({
      publicRoutes : ['/','/account','/contact','/order','/product/[category]']
});

it is giving me error when i am applying it , Please help me, i coudnt find any detail in docs

2

There are 2 answers

1
John On

Try adding "([^/.])", so it'll look like '/product/([^/.])', that saved me.

0
Beatrice Wambui Mbugua On

For the above, write your dynamic routes as such:

export default authMiddleware({
      publicRoutes : ['/', '/account', '/contact', '/order', '/product/(.*)']
});

The above '/product/(.*)' matches anything after the product route.