doomer
doomer3w ago

deploymentURL is undefined

When I use convex Auth with my next JS app, I get this error once in a few minutes:
GET /.well-known/appspecific/com.chrome.devtools.json 404 in 1045ms
deploymentUrl is undefined, are your environment variables set? In the future explicitly passing undefined will cause an error. To explicitly use the default, pass `process.env.NEXT_PUBLIC_CONVEX_URL`.
GET /.well-known/appspecific/com.chrome.devtools.json 404 in 1045ms
deploymentUrl is undefined, are your environment variables set? In the future explicitly passing undefined will cause an error. To explicitly use the default, pass `process.env.NEXT_PUBLIC_CONVEX_URL`.
app/layout.tsx:
import type { Metadata } from "next";
import { ThemeProvider } from "next-themes";
import "./globals.css";
import { ConvexAuthNextjsServerProvider } from "@convex-dev/auth/nextjs/server";
import ConvexClientProvider from "@/components/ConvexClientProvider";
import { NavigationWrapper } from "@/components/NavigationWrapper";
import { Toaster } from "@/components/ui/toaster";
import { SearchProvider } from "@/components/search/SearchProvider";

export const metadata: Metadata = {
title: "Pathways - Learning Path Builder",
description:
"Create and share curated learning pathways with organized resources",
icons: {
icon: "/convex.svg",
},
};

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<ConvexAuthNextjsServerProvider>
<html lang="en" suppressHydrationWarning>
<body className="antialiased">
<ThemeProvider
attribute="class"
defaultTheme="light"
enableSystem={false}
disableTransitionOnChange
forcedTheme="light"
>
<ConvexClientProvider>
<SearchProvider>
<NavigationWrapper />
<main className="min-h-[calc(100vh-3.5rem)]">{children}</main>
<Toaster />
</SearchProvider>
</ConvexClientProvider>
</ThemeProvider>
</body>
</html>
</ConvexAuthNextjsServerProvider>
);
}
import type { Metadata } from "next";
import { ThemeProvider } from "next-themes";
import "./globals.css";
import { ConvexAuthNextjsServerProvider } from "@convex-dev/auth/nextjs/server";
import ConvexClientProvider from "@/components/ConvexClientProvider";
import { NavigationWrapper } from "@/components/NavigationWrapper";
import { Toaster } from "@/components/ui/toaster";
import { SearchProvider } from "@/components/search/SearchProvider";

export const metadata: Metadata = {
title: "Pathways - Learning Path Builder",
description:
"Create and share curated learning pathways with organized resources",
icons: {
icon: "/convex.svg",
},
};

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<ConvexAuthNextjsServerProvider>
<html lang="en" suppressHydrationWarning>
<body className="antialiased">
<ThemeProvider
attribute="class"
defaultTheme="light"
enableSystem={false}
disableTransitionOnChange
forcedTheme="light"
>
<ConvexClientProvider>
<SearchProvider>
<NavigationWrapper />
<main className="min-h-[calc(100vh-3.5rem)]">{children}</main>
<Toaster />
</SearchProvider>
</ConvexClientProvider>
</ThemeProvider>
</body>
</html>
</ConvexAuthNextjsServerProvider>
);
}
9 Replies
Convex Bot
Convex Bot3w ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
erquhart
erquhart3w ago
Can you share your middleware
doomer
doomerOP2w ago
sorry I didn't get the notification. here's the middleware.ts:
import {
convexAuthNextjsMiddleware,
createRouteMatcher,
nextjsMiddlewareRedirect,
} from "@convex-dev/auth/nextjs/server";
import { NextResponse } from "next/server";

// Define route matchers
const isAuthPage = createRouteMatcher(["/login", "/register"]);
const isProtectedRoute = createRouteMatcher(["/dashboard(.*)"]);

export default convexAuthNextjsMiddleware(async (request, { convexAuth }) => {
const isAuthenticated = await convexAuth.isAuthenticated();
const { pathname, searchParams } = request.nextUrl;

// Handle auth pages (login, register)
if (isAuthPage(request) && isAuthenticated) {
// Check for returnUrl in query params
const returnUrl = searchParams.get("returnUrl");
if (returnUrl) {
try {
const decodedUrl = decodeURIComponent(returnUrl);
// Ensure the returnUrl is a relative path for security
if (decodedUrl.startsWith("/")) {
return NextResponse.redirect(new URL(decodedUrl, request.url));
}
} catch {
// Invalid returnUrl, ignore it
}
}
// Default redirect to dashboard
return nextjsMiddlewareRedirect(request, "/dashboard");
}

// Handle protected routes
if (isProtectedRoute(request) && !isAuthenticated) {
// Store the intended destination
const loginUrl = new URL("/login", request.url);
loginUrl.searchParams.set("returnUrl", encodeURIComponent(pathname));
return NextResponse.redirect(loginUrl);
}

// Public routes and optional auth routes pass through
return NextResponse.next();
});

export const config = {
// The following matcher runs middleware on all routes
// except static assets.
matcher: ["/((?!.*\\..*|_next).*)", "/", "/(api|trpc)(.*)"],
};
import {
convexAuthNextjsMiddleware,
createRouteMatcher,
nextjsMiddlewareRedirect,
} from "@convex-dev/auth/nextjs/server";
import { NextResponse } from "next/server";

// Define route matchers
const isAuthPage = createRouteMatcher(["/login", "/register"]);
const isProtectedRoute = createRouteMatcher(["/dashboard(.*)"]);

export default convexAuthNextjsMiddleware(async (request, { convexAuth }) => {
const isAuthenticated = await convexAuth.isAuthenticated();
const { pathname, searchParams } = request.nextUrl;

// Handle auth pages (login, register)
if (isAuthPage(request) && isAuthenticated) {
// Check for returnUrl in query params
const returnUrl = searchParams.get("returnUrl");
if (returnUrl) {
try {
const decodedUrl = decodeURIComponent(returnUrl);
// Ensure the returnUrl is a relative path for security
if (decodedUrl.startsWith("/")) {
return NextResponse.redirect(new URL(decodedUrl, request.url));
}
} catch {
// Invalid returnUrl, ignore it
}
}
// Default redirect to dashboard
return nextjsMiddlewareRedirect(request, "/dashboard");
}

// Handle protected routes
if (isProtectedRoute(request) && !isAuthenticated) {
// Store the intended destination
const loginUrl = new URL("/login", request.url);
loginUrl.searchParams.set("returnUrl", encodeURIComponent(pathname));
return NextResponse.redirect(loginUrl);
}

// Public routes and optional auth routes pass through
return NextResponse.next();
});

export const config = {
// The following matcher runs middleware on all routes
// except static assets.
matcher: ["/((?!.*\\..*|_next).*)", "/", "/(api|trpc)(.*)"],
};
And it also causes me to lose the authenticated user sometimes. So I have to log in again.
erquhart
erquhart2w ago
GET /.well-known/appspecific/com.chrome.devtools.json 404 in 1045ms
This appears to be related to Chrome Automatic Workspace Folders, not sure how to help there
deploymentUrl is undefined, are your environment variables set? In the future explicitly passing undefined will cause an error. To explicitly use the default, pass process.env.NEXT_PUBLIC_CONVEX_URL
This means you're not passing a value to new ConvexReactClient(), can you share the source for your ConvexClientProvider npx convex dev sets this automatically in your .env.local, so maybe this all somehow has to do with your Chrome Automatic Workspace Folder setup? If it's generally working but then sometimes not, not sure how that environment variable becomes undefined intermittently under normal usage.
doomer
doomerOP2w ago
ConvexClientProvider.tsx:
"use client";

import { ReactNode } from "react";
import { ConvexReactClient } from "convex/react";
import { ConvexAuthNextjsProvider } from "@convex-dev/auth/nextjs";

// Create a single instance of ConvexReactClient
const convex = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_URL!);

/**
* ConvexClientProvider - Wraps the application with Convex Auth context
* This Client Component provides both Convex functionality and authentication
* to all child components using Convex Auth
*/
export default function ConvexClientProvider({
children,
}: {
children: ReactNode;
}) {
return (
<ConvexAuthNextjsProvider client={convex}>
{children}
</ConvexAuthNextjsProvider>
);
}
"use client";

import { ReactNode } from "react";
import { ConvexReactClient } from "convex/react";
import { ConvexAuthNextjsProvider } from "@convex-dev/auth/nextjs";

// Create a single instance of ConvexReactClient
const convex = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_URL!);

/**
* ConvexClientProvider - Wraps the application with Convex Auth context
* This Client Component provides both Convex functionality and authentication
* to all child components using Convex Auth
*/
export default function ConvexClientProvider({
children,
}: {
children: ReactNode;
}) {
return (
<ConvexAuthNextjsProvider client={convex}>
{children}
</ConvexAuthNextjsProvider>
);
}
I'm using ConvexAuthNextjsProvider as it's recommended to be used with convex auth in a next js project
erquhart
erquhart2w ago
The deploymentUrl error is saying process.env.NEXT_PUBLIC_CONVEX_URL isn't defined Is it defined in your .env.local
doomer
doomerOP2w ago
yes. The project does get launched properly and I can use it. But this deploymentURL issue will occur once in a while as the project is already running. In most cases, it doesn't break the app. It refreshes and I can keep using the application. But sometimes it will disrupt the connectiion with convex and sometimes the authenticated session will get lost and I'll have to login again.
erquhart
erquhart2w ago
Are you using chrome automatic workspace folders? That's where this error seems to be starting, I suspect it's causing issues when running locally. Curious if this happens in your production deployment from a production site with no dev tooling running in chrome. (or just try accessing your dev site from a different browser)
doomer
doomerOP2w ago
no. when I use firefox, I get don't get the chrome error. I just get his:
deploymentUrl is undefined, are your environment variables set? In the future explicitly passing undefined will cause an error. To explicitly use the default, pass `process.env.NEXT_PUBLIC_CONVEX_URL`.
8/30/2025, 6:59:16 PM [CONVEX M(auth:store)] [INFO] '`auth:store` type: refreshSession'
deploymentUrl is undefined, are your environment variables set? In the future explicitly passing undefined will cause an error. To explicitly use the default, pass `process.env.NEXT_PUBLIC_CONVEX_URL`.
8/30/2025, 6:59:16 PM [CONVEX M(auth:store)] [INFO] '`auth:store` type: refreshSession'
I can also see this on chrome tho:
8/30/2025, 6:59:16 PM [CONVEX M(auth:store)] [INFO] '`auth:store` type: refreshSession'
8/30/2025, 6:59:16 PM [CONVEX M(auth:store)] [INFO] '`auth:store` type: refreshSession'
Although I have not tested thoroughly, I think I stopped getting this error when I avoided using the convex auth. Or perhaps, it was caused by ConvexAuthNextjsProvider I plan to test it out properly.

Did you find this page helpful?