diff --git a/.replit b/.replit index a32138b6..07348546 100644 --- a/.replit +++ b/.replit @@ -52,10 +52,6 @@ externalPort = 80 localPort = 8044 externalPort = 3003 -[[ports]] -localPort = 35709 -externalPort = 3002 - [[ports]] localPort = 38557 externalPort = 3000 diff --git a/client/lib/supabase-service.ts b/client/lib/supabase-service.ts index d1a6af21..959b2adb 100644 --- a/client/lib/supabase-service.ts +++ b/client/lib/supabase-service.ts @@ -400,21 +400,31 @@ export const communityService = { "id" | "created_at" | "updated_at" | "likes_count" | "comments_count" >, ): Promise { + const apiUrl = `${API_BASE}/api/posts`; + console.log("[createPost] Attempting POST to:", apiUrl); + console.log("[createPost] Payload:", JSON.stringify(post).slice(0, 200)); + try { - const resp = await fetch(`${API_BASE}/api/posts`, { + const resp = await fetch(apiUrl, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(post), }); + console.log("[createPost] Response status:", resp.status, resp.statusText); + if (resp.ok) { - return (await resp.json()) as CommunityPost; + const json = await resp.json(); + console.log("[createPost] Success:", json?.id); + return json as CommunityPost; } if (resp.status >= 400) { - const payload = await resp.json().catch(() => ({})); + const text = await resp.text(); + console.error("[createPost] API error response:", text.slice(0, 500)); + const payload = text ? JSON.parse(text) : {}; throw new Error(payload?.error || `API responded with ${resp.status}`); } - } catch (error) { - console.warn("Falling back to Supabase insert for post:", error); + } catch (error: any) { + console.error("[createPost] Fetch error:", error?.message || error); } const { data, error } = await supabase