Marcus
Marcus
WWasp
Created by Marcus on 2/5/2025 in #🙋questions
Wasp API Route Not Found (404) for Langflow Integration in GitHub Codespaces
📌 Wasp API Route Not Found (404) for Langflow Integration in GitHub Codespaces Hey everyone,
I'm working on integrating Langflow into my Wasp (v0.16.0) project inside a GitHub Codespace, but I'm running into a 404 Not Found issue when my frontend tries to call the API route.
--- 🛠️ Setup & What I'm Trying to Do - Using Wasp (v0.16.0). - Running the app inside a GitHub Codespace. - Trying to create an API endpoint (/api/runLangflow) that my frontend can call to interact with Langflow. --- 📌 What I’ve Done So Far 1️⃣ Defined the API route in main.wasp:
api runLangflow {
fn: import { runLangflow } from "@src/demo-ai-app/operations",
entities: [User],
httpRoute: (POST, "/api/runLangflow")
}
api runLangflow {
fn: import { runLangflow } from "@src/demo-ai-app/operations",
entities: [User],
httpRoute: (POST, "/api/runLangflow")
}
2️⃣ Created the function in operations.ts:
import { LangflowClient } from "./langflow";

{API Keys}

const langflowClient = new LangflowClient(
{ENV}
);

export async function runLangflow({ input }: { input: string }) {
try {
const response = await langflowClient.runFlow(input);
return response;
} catch (e) {
console.error("Error running Langflow:", e);
throw e;
}
}
import { LangflowClient } from "./langflow";

{API Keys}

const langflowClient = new LangflowClient(
{ENV}
);

export async function runLangflow({ input }: { input: string }) {
try {
const response = await langflowClient.runFlow(input);
return response;
} catch (e) {
console.error("Error running Langflow:", e);
throw e;
}
}
###3️⃣ Updated my frontend to call /api/runLangflow:
const response = await fetch("/api/runLangflow", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ input: userMessage }),
});
const response = await fetch("/api/runLangflow", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ input: userMessage }),
});
Issues - /api/runLangflow doesn't appear in wasp info, meaning it’s not being registered. - Running curl to /api/runLangflow also returns a 404 Not Found. What Could Be Causing This? - Is Wasp not recognizing the API definition? - Do I need to expose the API differently in GitHub Codespaces? - Does Wasp handle API routes differently in Codespaces? Would really appreciate any help! Thanks in advance. 🚀😊
11 replies