Next.js Discord

Discord Forum

How to build with relative paths?

Unanswered
Texas leafcutting ant posted this in #help-forum
Open in Discord
Avatar
Texas leafcutting antOP
Hello,
when creating apps with Vite I'm using a relative base path . because the page might not be served under root.

How do I achieve this with Next?

I tried basePath: '.', ( https://nextjs.org/docs/app/api-reference/config/next-config-js/basePath ) but this is not allowed. The path must start with a slash.

Should I use https://nextjs.org/docs/app/api-reference/config/next-config-js/assetPrefix instead? But the docs clearly say

Good to know: Next.js 9.5+ added support for a customizable Base Path, which is better suited for hosting your application on a sub-path like /docs. We do not suggest you use a custom Asset Prefix for this use case.

0 Replies