#Can't get Intercepting Routes to work with rewrites

2 messages · Page 1 of 1 (latest)

glossy lantern
#

I've managed to get intercepting routes working with parallel routing to create modals like in https://nextjs.org/docs/app/building-your-application/routing/intercepting-routes#examples .

I'm using this so that any pages in /item/my-item-id appear as a popup/modal.

However I am also using a rewrite to change /@steve to /user/steve. Without this rewrite the interception works fine, however as soon as I enable it it stops working for all pages (so links to /item from /about stop working as a modal).

Although if I rewrite from /@/steve to /user/steve it works completely fine. I think this may be a bug in next with changing from 2 "path levels" to 1, but I just wanted to check I wasn't configuring something incorrectly.

  rewrites: async () => {
    return [
      {
        source: "/@:username",
        destination: "/user/:username",
      },
    ];
  },

This is my rewrites in next config. I've also tried it as a beforeFiles, afterFiles and Fallback, but none of them seem to work.

Use intercepting routes to load a new route within the current layout while masking the browser URL, useful for advanced routing patterns such as modals.

plucky tulipBOT
#

🔎 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)