I tried looking in the documentation but can’t seem to find it.
I want to disable some code when running under v0, initially the workos integration, but there may be others later on.
I trued setting an environment variable USING_V0=true inside of v0, but then it was added to my vercel project.
I’m at a loss at what I can do, I’d like to keep the environment of the vercel project separate, or at least is there a way to tell the code is under v0, and I can check that instead of using my hacky environment variable.
Here’s what I’m doing now (in one of a few places) - any advice is appreciated. Thanks!!
const isV0Preview = process.env.USING_V0 === "true"
const hasWorkOSConfig = process.env.WORKOS_CLIENT_ID && process.env.WORKOS_API_KEY && process.env.WORKOS_COOKIE_PASSWORD
// Skip authentication in v0 preview or when WorkOS is not configured
if (isV0Preview || !hasWorkOSConfig) {
console.log("[v0] Skipping WorkOS auth middleware - not configured")
return NextResponse.next()
}
I was just coding up something similiar after looking at all of the environment variables on my local machine running the code under vscode, on v0 and also on a production deployment on vercel. Since I need this on server side, I went with this, let me know any obvious flaws (apart from your comment that vusercontent.net may not last forever). I was also thinking the VERCEL_PROJECT_ID is empty on v0 and may be a good check instead.