Next.js Discord

Discord Forum

Rewrites not working (next config)

Answered
Arinji posted this in #help-forum
Open in Discord
Ok so i have this code in my next config
  async rewrites() {
    return [
      {
        source: "/",
        destination: "/software/vanilla",
      },
    ];
  },


However the rewrites dont need to be working,
Source: https://startminecraft.com/
Destination: https://startminecraft.com/software/vanilla

I want the source page to match the data of the destination page :D
Answered by riský
you may be having a homepage already, so what i did was made use of the beforeFiles option for that
View full answer

14 Replies

Answer
Woah never knew this beforeFiles and stuff existed
it took me like a hour to work out why i couldnt scam rewrite away my homepage if logged in 😭
i have since rewrited my root (/) to /home instead, but still use beforeFiles as it makes more sense to me
@riský you may be having a homepage already, so what i did was made use of the `beforeFiles` option for that
Why do you think I made the forum hehe, I knew you had messed around with rewrites before :) this shit hella magical xD
half of my chaos will never been documented anywhere, so this is good ig so others can search on google :)
Def
Imma test it out, one sec
but once you read the docs very carefully, your like this makes sense... why didnt i realise
@riský just to check,
async rewrites() {
    return {
      beforeFiles: [
        {
          source: "/",
          destination: "/software/vanilla",
        },
      ],
    };
  },


something like this right?
should be
Works perfectly, thanks for the help :D
Enjoy the point xD, you could use some