301 Redirects in Next.js without passing the query from source URL to destination URL

  1. Есть source-URL вида https://example.com/category/results/refine?dealers=123&inv=true&sellertypes=dealer

  2. Хочется перманентно (301) редиректить этот source-URL на destination-URL вида https://example.com/ при условии если source-URL в query содержит ключи dealers (любые) и inv (в значении true).

  3. В соответствии с документацией Next.js реализовал следующее в next.config.ts:

    async redirects() {
     return [
       {
         source: "/category/results/refine",
         has: [
           {
             type: "query",
             key: "dealers",
           },
           {
             type: "query",
             key: "inv",
             value: "true",
           },
         ],
         destination: "/",
         permanent: true,
         statusCode: 301,
       },
     }
    
  4. Но вместо редиректа на https://example.com/ получаю редирект на https://example.com/?dealers=123&inv=true&sellertypes=dealer. То есть query из source-URL приклеивается к destination-URL, а мне надо чтобы последний был без query.


Ответы (0 шт):