Next.js Discord

Discord Forum

Intercepting routes not executing on rewrite

Unanswered
New Guinea Freshwater Crocodile posted this in #help-forum
Open in Discord
New Guinea Freshwater CrocodileOP
Hi, I have refactored my application the way I've nested entire web to it's own directory, so I can have another directory for emails without a website layout (please see the structure below). Subsequently I've used next rewrites to redirect all routes to correct path and the issue I am experiencing now is my intercepting modal stopped work. Could you please help me to understand why is it happening and how to fix it? I assume the problem will be in rewrite all /:path*

1 Reply

New Guinea Freshwater CrocodileOP
App directory structure
app/
├── api
│   ├── _cms
│   ├── download
│   │   └── route.ts
│   ├── emails
│   │   └── orders
│   │       └── summary
│   │           └── [id]
│   │               ├── route.ts
│   │               └── summary.email.tsx
│   ├── preview
│   │   └── route.ts
│   └── revalidate
│       └── route.ts
├── emails
│   └── orders
│       └── [id]
│           └── page.tsx
├── layout.tsx
├── styles.ts
└── website
    ├── @modal
    │   ├── (.)gallery
    │   │   └── [id]
    │   │       └── page.tsx
    │   ├── Modal.tsx
    │   ├── [...]
    │   │   └── page.tsx
    │   └── default.tsx
    ├── cart
    │   ├── checkout
    │   │   └── page.tsx
    │   ├── layout.tsx
    │   └── page.tsx
    ├── gallery
    │   └── [id]
    │       └── page.tsx
    ├── globals.css
    ├── layout.tsx
    ├── legal
    │   └── [slug]
    │       └── page.tsx
    ├── lib
    │   ├── ...
    ├── not-found.tsx
    └── page.tsx

49 directories, 129 files


Rewrites:
async rewrites() {
    return [
      {
        source: "/",
        destination: "/website/",
      },
      {
        source: "/media/:id*",
        destination:
          process.env.NODE_ENV === "production"
            ? "***/assets/:id*"
            : "***/assets/:id*",
      },
      {
        source: "/e/:path*",
        destination: "/emails/:path*",
      },
      {
        source: "/api/:path*",
        destination: "/api/:path*",
      },
      {
        source: "/:path*",
        destination: "/website/:path*",
        
      },
    ];
  },