fix: ensure convex client fallback url
This commit is contained in:
parent
36fe4a7943
commit
3565500e9c
3 changed files with 10 additions and 11 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { ConvexHttpClient } from "convex/browser"
|
||||
|
||||
import { env } from "@/lib/env"
|
||||
import { DEFAULT_CONVEX_URL } from "@/lib/constants"
|
||||
|
||||
export class ConvexConfigurationError extends Error {
|
||||
constructor(message = "Convex não configurado.") {
|
||||
|
|
@ -15,8 +16,8 @@ function isServerSide() {
|
|||
|
||||
export function requireConvexUrl(): string {
|
||||
const url = isServerSide()
|
||||
? env.CONVEX_INTERNAL_URL ?? env.NEXT_PUBLIC_CONVEX_URL
|
||||
: env.NEXT_PUBLIC_CONVEX_URL
|
||||
? env.CONVEX_INTERNAL_URL ?? env.NEXT_PUBLIC_CONVEX_URL ?? DEFAULT_CONVEX_URL
|
||||
: env.NEXT_PUBLIC_CONVEX_URL ?? DEFAULT_CONVEX_URL
|
||||
if (!url) {
|
||||
throw new ConvexConfigurationError()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue