micheleriva / krabs

🦀 Express.js/Fastify middleware and virtual host for multi-tenant Next.js applications
https://krabs.vercel.app
MIT License
363 stars 28 forks source link

rewrites dont work #28

Closed AhmadAbuyahya closed 2 years ago

AhmadAbuyahya commented 3 years ago

I want to add certain rewrites to one of my domains and it doesn't seem to work, this is what my next.config.js looks like:

module.exports = {
    async rewrites() {
        return [
            {
                source: '/someroute',
                destination: '/somepage',
            },
        ]
    },
}

I also tried adding the tenant name before and it also didn't work:

module.exports = {
    async rewrites() {
        return [
            {
                source: '/tenant/someroute',
                destination: '/tenant/somepage',
            },
        ]
    },
}

any help would be appreciated

KjellConnelly commented 3 years ago

This is how I use rewrites for catch-all route slugs... Maybe it'll give you some inspiration:

{
   source: '/blog/:slug*',
   destination: '/website1/blog/:slug*',
},
micheleriva commented 3 years ago

Hi @AhmadAbuyahya, you can handle rewrites on the Express.js/Fastify level

AhmadAbuyahya commented 3 years ago

Hi @AhmadAbuyahya, you can handle rewrites on the Express.js/Fastify level

is there no way to handle them from next?

micheleriva commented 3 years ago

@AhmadAbuyahya I think Express/Fastify could do that natively, so I'd suggest using them!