Build: make server-only imports dynamic in analyze route to avoid client bundling errors\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
import { OpenRouterClient } from "../../lib/openrouter";
|
||||
import { TradingGraph } from "../../agents/tradingGraph";
|
||||
import { db } from "../../lib/db.server";
|
||||
import { fetchAccount, fetchRecentCloses } from "../../lib/alpacaClient";
|
||||
// Server-only imports are loaded dynamically inside the action to avoid client bundling issues
|
||||
|
||||
export async function action({ request }: { request: Request }) {
|
||||
console.log("[analyze] Request received:", request.method, request.url);
|
||||
@@ -17,6 +14,12 @@ export async function action({ request }: { request: Request }) {
|
||||
return Response.json({ error: "ticker is required" }, { status: 400 });
|
||||
}
|
||||
|
||||
// Load server-only modules dynamically to prevent them from being included in client bundles
|
||||
const { OpenRouterClient } = await import("../../lib/openrouter");
|
||||
const { TradingGraph } = await import("../../agents/tradingGraph");
|
||||
const { db } = await import("../../lib/db.server");
|
||||
const { fetchAccount, fetchRecentCloses } = await import("../../lib/alpacaClient");
|
||||
|
||||
const apiKey = process.env.OPENROUTER_API_KEY;
|
||||
console.log("[analyze] API key configured:", !!apiKey, apiKey?.substring(0, 10) + "...");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user