Open robbear opened 2 years ago
This is related to the i18n middleware I believe. So if you don't have i18n enabled it should be working fine.
As a workaround, you can use middleware.ts
to handle redirects.
I also couldn't find a way to use Next's inbuilt redirect functionality (https://nextjs.org/docs/api-reference/next.config.js/redirects).
Seems like we can pass other Next.js config as parameters but I don't know how I can pass the redirects()
function as a parameter.
My configuration file is like so. Trying this way, the redirects didn't work:
const withNextra = require('nextra')({
theme: 'nextra-theme-docs',
themeConfig: './theme.config.tsx',
staticImage: true,
flexsearch: {
codeblocks: false
},
defaultShowCopyCode: true,
async redirects() {
return [
{
source: '/test',
destination: '/testing',
permanent: true,
},
]
},
})
module.exports = withNextra()
// If you have other Next.js configurations, you can pass them as the parameter:
// module.exports = withNextra({ /* other next.js config */ })```
Hi there @evrifaessa Maybe a silly thing, but did you try to restart a project... because redirect worked for me with the same config.
I also couldn't find a way to use Next's inbuilt redirect functionality (https://nextjs.org/docs/api-reference/next.config.js/redirects).
Seems like we can pass other Next.js config as parameters but I don't know how I can pass the
redirects()
function as a parameter.My configuration file is like so. Trying this way, the redirects didn't work:
const withNextra = require('nextra')({ theme: 'nextra-theme-docs', themeConfig: './theme.config.tsx', staticImage: true, flexsearch: { codeblocks: false }, defaultShowCopyCode: true, async redirects() { return [ { source: '/test', destination: '/testing', permanent: true, }, ] }, }) module.exports = withNextra() // If you have other Next.js configurations, you can pass them as the parameter: // module.exports = withNextra({ /* other next.js config */ })```
i fixed this by adding it to module.exports instead. here's my working snippet:
const withNextra = require("nextra")({
defaultShowCopyCode: true,
latex: true,
theme: "nextra-theme-docs",
themeConfig: "./theme.config.tsx",
});
module.exports = withNextra({
async redirects() {
return [
{
source: "/hello",
destination: "/world",
permanent: true,
},
];
},
});
The SWR site example specifies
redirects
innext.config.js
but these don't appear to be working. I'm actually looking for guidance on how to configure those redirects, myself.Ex:
/docs
is supposed to redirect to/docs/getting-started
but it leads instead to a404