We have 2 sites hosted within vercel using next.js and a monorepo
next.config has rewrites setup
rewrites: () => {
const rewrites = [];
if (process.env.NEXT_PUBLIC_SITE === "sitea") {
rewrites.push({
source: "/siteb{/}?",
destination: "https://siteb.vercel.app",
});
rewrites.push({
source: "/siteb/:path*",
destination: "https://siteb.vercel.app/:path*",
});
rewrites.push({
source: "/testing{/}?",
destination: `https://example.com/`,
});
}
return {
beforeFiles: rewrites,
}
},
This was all working as expected
user visits https://example.com/ and sees sitea
user visits https://example.com/siteb/ and sees siteb without being redirected
recently however if
user visits https://example.com/siteb/ they are being 308 redirected to https://siteb.vercel.app/ which is not the intended behaviour
for testing i’ve added another rewrite to a url not hosted on vercel and can see that working as expected.