Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(bug): derive fallback asset URL from request origin instead of hardcoded localhost:1337

randoneering686a0cbd3318
diff --git a/apps/api/src/task/index.ts b/apps/api/src/task/index.ts
index 464952f55..831e63b1d 100644
--- a/apps/api/src/task/index.ts
+++ b/apps/api/src/task/index.ts
@@ -804,7 +804,7 @@ const task = new Hono<{
});
const apiBaseUrl = normalizeApiServerUrl(
- process.env.KANEO_API_URL || "http://localhost:1337",
+ process.env.KANEO_API_URL || new URL(c.req.url).origin,
);
return c.json({
id: asset.id,
diff --git a/tests/api-integration/task-image-upload.test.ts b/tests/api-integration/task-image-upload.test.ts
index 8df8db2dd..dc3c51e94 100644
--- a/tests/api-integration/task-image-upload.test.ts
+++ b/tests/api-integration/task-image-upload.test.ts
@@ -124,7 +124,7 @@ describe("API integration: task image upload finalize", () => {
expect(payload.url).not.toContain("localhost");
});
- it("falls back when KANEO_API_URL is not set", async () => {
+ it("falls back to deriving URL from the request when KANEO_API_URL is not set", async () => {
delete process.env.KANEO_API_URL;
const member = await createWorkspaceMember();
@@ -152,7 +152,7 @@ describe("API integration: task image upload finalize", () => {
const key = `workspace/${member.workspace.id}/project/${project.id}/task/${task.id}/descriptions/fallback-image.png`;
const response = await app.request(
- `/api/task/image-upload/${task.id}/finalize`,
+ `https://app.kaneo.test/api/task/image-upload/${task.id}/finalize`,
{
method: "POST",
headers: { "content-type": "application/json" },
@@ -168,7 +168,8 @@ describe("API integration: task image upload finalize", () => {
expect(response.status).toBe(200);
const payload = (await response.json()) as { id: string; url: string };
- expect(payload.url).toBe(`http://localhost:1337/api/asset/${payload.id}`);
+ expect(payload.url).toBe(`https://app.kaneo.test/api/asset/${payload.id}`);
+ expect(payload.url).not.toContain("localhost");
});
it("persists a new asset record with correct metadata", async () => {