This commit is contained in:
parent
d4419293fb
commit
83850fc475
|
|
@ -6,7 +6,7 @@ import { ServerRuntime } from "next"
|
||||||
import OpenAI from "openai"
|
import OpenAI from "openai"
|
||||||
import { ChatCompletionCreateParamsBase } from "openai/resources/chat/completions.mjs"
|
import { ChatCompletionCreateParamsBase } from "openai/resources/chat/completions.mjs"
|
||||||
//import { getRuntimeEnv } from "@/lib/ipconfig" // 新增引入
|
//import { getRuntimeEnv } from "@/lib/ipconfig" // 新增引入
|
||||||
import { getRuntimeEnv } from "@/lib/runtime-env"
|
import { getRuntimeEnvForRouterAPI } from "@/lib/runtime-env"
|
||||||
|
|
||||||
|
|
||||||
//export const runtime: ServerRuntime = "edge"
|
//export const runtime: ServerRuntime = "edge"
|
||||||
|
|
@ -21,14 +21,14 @@ export async function POST(request: Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// const supabaseAdmin = createClient<Database>(
|
|
||||||
// getRuntimeEnv("SUPABASE_URL") ?? "http://localhost:8000",
|
|
||||||
// process.env.SUPABASE_SERVICE_ROLE_KEY!
|
|
||||||
// )
|
|
||||||
const supabaseAdmin = createClient<Database>(
|
const supabaseAdmin = createClient<Database>(
|
||||||
"http://67.223.119.33:8000", // ⬅️ 硬编码 IP 地址
|
getRuntimeEnvForRouterAPI("SUPABASE_URL") ?? "http://localhost:8000",
|
||||||
process.env.SUPABASE_SERVICE_ROLE_KEY!
|
process.env.SUPABASE_SERVICE_ROLE_KEY!
|
||||||
)
|
)
|
||||||
|
// const supabaseAdmin = createClient<Database>(
|
||||||
|
// "http://67.223.119.33:8000", // ⬅️ 硬编码 IP 地址
|
||||||
|
// process.env.SUPABASE_SERVICE_ROLE_KEY!
|
||||||
|
// )
|
||||||
|
|
||||||
const { data: customModel, error } = await supabaseAdmin
|
const { data: customModel, error } = await supabaseAdmin
|
||||||
.from("models")
|
.from("models")
|
||||||
|
|
@ -39,7 +39,7 @@ export async function POST(request: Request) {
|
||||||
console.log("⛳ ChatSettings:", chatSettings)
|
console.log("⛳ ChatSettings:", chatSettings)
|
||||||
console.log("⛳ Messages:", messages)
|
console.log("⛳ Messages:", messages)
|
||||||
console.log("⛳ Custom Model ID:", customModelId)
|
console.log("⛳ Custom Model ID:", customModelId)
|
||||||
console.log("⛳ Supabase URL:", getRuntimeEnv("SUPABASE_URL"))
|
console.log("⛳ Supabase URL:", getRuntimeEnvForRouterAPI("SUPABASE_URL"))
|
||||||
|
|
||||||
if (!customModel) {
|
if (!customModel) {
|
||||||
console.error("❌ No custom model found:", error)
|
console.error("❌ No custom model found:", error)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { Database } from "@/supabase/types"
|
import { Database } from "@/supabase/types"
|
||||||
import { createClient } from "@supabase/supabase-js"
|
import { createClient } from "@supabase/supabase-js"
|
||||||
//import { getRuntimeEnv } from "@/lib/ipconfig" // 新增引入
|
//import { getRuntimeEnv } from "@/lib/ipconfig" // 新增引入
|
||||||
import { getRuntimeEnv } from "@/lib/runtime-env"
|
import { getRuntimeEnvForRouterAPI } from "@/lib/runtime-env"
|
||||||
|
|
||||||
export const runtime = "edge"
|
export const runtime = "edge"
|
||||||
|
|
||||||
|
|
@ -13,7 +13,7 @@ export async function POST(request: Request) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const supabaseAdmin = createClient<Database>(
|
const supabaseAdmin = createClient<Database>(
|
||||||
getRuntimeEnv("SUPABASE_URL") ?? "http://localhost:8000",
|
getRuntimeEnvForRouterAPI("SUPABASE_URL") ?? "http://localhost:8000",
|
||||||
process.env.SUPABASE_SERVICE_ROLE_KEY!
|
process.env.SUPABASE_SERVICE_ROLE_KEY!
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { Database } from "@/supabase/types"
|
import { Database } from "@/supabase/types"
|
||||||
import { createClient } from "@supabase/supabase-js"
|
import { createClient } from "@supabase/supabase-js"
|
||||||
//import { getRuntimeEnv } from "@/lib/ipconfig" // 新增引入
|
//import { getRuntimeEnv } from "@/lib/ipconfig" // 新增引入
|
||||||
import { getRuntimeEnv } from "@/lib/runtime-env"
|
import { getRuntimeEnvForRouterAPI } from "@/lib/runtime-env"
|
||||||
|
|
||||||
export const runtime = "edge"
|
export const runtime = "edge"
|
||||||
|
|
||||||
|
|
@ -13,7 +13,7 @@ export async function POST(request: Request) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const supabaseAdmin = createClient<Database>(
|
const supabaseAdmin = createClient<Database>(
|
||||||
getRuntimeEnv("SUPABASE_URL") ?? "http://localhost:8000",
|
getRuntimeEnvForRouterAPI("SUPABASE_URL") ?? "http://localhost:8000",
|
||||||
process.env.SUPABASE_SERVICE_ROLE_KEY!
|
process.env.SUPABASE_SERVICE_ROLE_KEY!
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,3 +8,7 @@ export function getRuntimeEnv(key: string): string | undefined {
|
||||||
return getRuntimeEnvCSR(key)
|
return getRuntimeEnvCSR(key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getRuntimeEnvForRouterAPI(key: string): string | undefined {
|
||||||
|
return process.env[key]
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue