mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
Fix openrouter proxy baseURL to honor FORWARD_TO_PRODUCTION
Previously the AI proxy baseURL was chosen based on NODE_ENV alone, which caused dev requests to loop back to the local proxy and forward "Bearer FORWARD_TO_PRODUCTION" upstream. Switch on the env var instead and use NEXT_PUBLIC_STACK_API_URL as the default base.
This commit is contained in:
parent
f7c6e69704
commit
7d466f6b00
@ -1,5 +1,5 @@
|
||||
import { createOpenRouter } from "@openrouter/ai-sdk-provider";
|
||||
import { getNodeEnvironment } from "@stackframe/stack-shared/dist/utils/env";
|
||||
import { getEnvVariable } from "@stackframe/stack-shared/dist/utils/env";
|
||||
|
||||
export type ModelQuality = "dumb" | "smart" | "smartest";
|
||||
export type ModelSpeed = "slow" | "fast";
|
||||
@ -59,9 +59,9 @@ export const ALLOWED_MODEL_IDS: ReadonlySet<string> = new Set([
|
||||
]);
|
||||
|
||||
export function createOpenRouterProvider() {
|
||||
const baseURL = getNodeEnvironment() === "development"
|
||||
? "http://localhost:8102/api/latest/integrations/ai-proxy/v1"
|
||||
: "https://api.stack-auth.com/api/latest/integrations/ai-proxy/v1";
|
||||
const baseURL = getEnvVariable("STACK_OPENROUTER_API_KEY", "") === "FORWARD_TO_PRODUCTION"
|
||||
? "https://api.stack-auth.com/api/latest/integrations/ai-proxy/v1"
|
||||
: `${getEnvVariable("NEXT_PUBLIC_STACK_API_URL")}/api/latest/integrations/ai-proxy/v1`;
|
||||
return createOpenRouter({
|
||||
apiKey: "forwarded",
|
||||
baseURL,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user