Capítulo 200 de 456
Config option to deploy a Next.js app under a sub-path of a domain (e.g. /docs), automatically applied to next/link/next/router links and requiring manual prefixing for next/image sources.
module.exports = {
basePath: '/docs',
}
export default function HomePage() {
return <Link href="/about">About Page</Link>
}
// output: <a href="/docs/about">About Page</a>
basePath: '/docs', um href="/about" é automaticamente reescrito para /docs/about no HTML gerado.import Image from 'next/image'
function Home() {
return <Image src="/docs/me.png" alt="Picture of the author" width={500} height={500} />
}
<Link>, next/image exige que você prefixe src manualmente com o basePath.next/image aplique o basePath automaticamente: não aplica; o src precisa incluir o prefixo manualmente.basePath sem rebuild: o valor é inlined nos bundles client-side em build time.<Link>/next/router aplicam basePath automaticamente, evitando reescrever todos os links da app.next/image é uma exceção: src precisa incluir o prefixo manualmente.''.basePath diverge (automático vs. manual).