#Remove Base Path from the url
8 messages · Page 1 of 1 (latest)
🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord
🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize
✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)
const isProd = process.env.NODE_ENV === 'production'
module.exports = {
basePath: isProd ? '' : '/your_dev_path',
}
Hi, you can do that by checking if the environment is in production or development. Take a look at the example below:
const apiUrl = process.env.NEXT_PUBLIC_PROD_API_URL // https://somewhere.com
const devApiUrl = process.env.NEXT_PUBLIC_DEV_API_URL // localhost:3000
export const API_URL = process.env.NODE_ENV === "production" ? apiUrl : devApiUrl
thanks for the response!
We are running turborepo with 3 apps in a single domain, all of the 3 nextjs app has base path so that the cloudfront can know which apps send a request, but in production we want to remove the base-path, is it still possible?
I don't have prior knowledge of using turborepo but maybe the rewrites function next.js would help you.
const moduleExports = {
basePath: '/app',
async rewrites () {
return [
{
source: '/a/:path*',
destination: '/app/a/:path*',
},
]
},
};
Source: https://nextjs.org/docs/app/api-reference/next-config-js/rewrites
is there a way to remove basePath on router.push("/path") ?