feat(convex): add internal url and remote access fixes
This commit is contained in:
parent
feb31d48c1
commit
da46fa448b
17 changed files with 73 additions and 92 deletions
|
|
@ -2,9 +2,9 @@ import { NextResponse } from "next/server"
|
|||
import { ConvexHttpClient } from "convex/browser"
|
||||
import { api } from "@/convex/_generated/api"
|
||||
import type { Id } from "@/convex/_generated/dataModel"
|
||||
import { env } from "@/lib/env"
|
||||
import { assertAuthenticatedSession } from "@/lib/auth-server"
|
||||
import { DEFAULT_TENANT_ID } from "@/lib/constants"
|
||||
import { requireConvexUrl } from "@/server/convex-client"
|
||||
|
||||
export const runtime = "nodejs"
|
||||
|
||||
|
|
@ -42,11 +42,6 @@ export async function GET(request: Request) {
|
|||
return NextResponse.json({ items: [] }, { status: 401 })
|
||||
}
|
||||
|
||||
const convexUrl = env.NEXT_PUBLIC_CONVEX_URL
|
||||
if (!convexUrl) {
|
||||
return NextResponse.json({ items: [] }, { status: 500 })
|
||||
}
|
||||
|
||||
const normalizedRole = normalizeRole(session.user.role)
|
||||
const isAgentOrAdmin = normalizedRole === "admin" || normalizedRole === "agent"
|
||||
const canLinkOwnTickets = normalizedRole === "collaborator"
|
||||
|
|
@ -59,7 +54,7 @@ export async function GET(request: Request) {
|
|||
const rawQuery = url.searchParams.get("q") ?? ""
|
||||
const query = rawQuery.trim()
|
||||
|
||||
const client = new ConvexHttpClient(convexUrl)
|
||||
const client = new ConvexHttpClient(requireConvexUrl())
|
||||
|
||||
// Garantir que o usuário exista no Convex para obter viewerId
|
||||
let viewerId: string | null = null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue