Add logging to track post creation and API fallback
Add detailed console logs to the `createPost` function to trace API calls, successful responses, errors, and fallback to direct Supabase inserts, skipping Discord synchronization. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9203795e-937a-4306-b81d-b4d5c78c240e Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: feb37d47-5b11-4872-820a-7df0da43eae9 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7c94b7a0-29c7-4f2e-94ef-44b2153872b7/9203795e-937a-4306-b81d-b4d5c78c240e/duiWnI1 Replit-Helium-Checkpoint-Created: true
This commit is contained in:
commit
51f7fd0d59
2 changed files with 9 additions and 3 deletions
2
.replit
2
.replit
|
|
@ -61,7 +61,7 @@ localPort = 40437
|
||||||
externalPort = 3001
|
externalPort = 3001
|
||||||
|
|
||||||
[[ports]]
|
[[ports]]
|
||||||
localPort = 43741
|
localPort = 41051
|
||||||
externalPort = 3002
|
externalPort = 3002
|
||||||
|
|
||||||
[deployment]
|
[deployment]
|
||||||
|
|
|
||||||
|
|
@ -400,23 +400,29 @@ export const communityService = {
|
||||||
"id" | "created_at" | "updated_at" | "likes_count" | "comments_count"
|
"id" | "created_at" | "updated_at" | "likes_count" | "comments_count"
|
||||||
>,
|
>,
|
||||||
): Promise<CommunityPost> {
|
): Promise<CommunityPost> {
|
||||||
|
console.log("[createPost] Starting - calling API at", `${API_BASE}/api/posts`);
|
||||||
try {
|
try {
|
||||||
const resp = await fetch(`${API_BASE}/api/posts`, {
|
const resp = await fetch(`${API_BASE}/api/posts`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify(post),
|
body: JSON.stringify(post),
|
||||||
});
|
});
|
||||||
|
console.log("[createPost] API response status:", resp.status);
|
||||||
if (resp.ok) {
|
if (resp.ok) {
|
||||||
return (await resp.json()) as CommunityPost;
|
const result = await resp.json();
|
||||||
|
console.log("[createPost] API success - post created via API (Discord sync enabled)");
|
||||||
|
return result as CommunityPost;
|
||||||
}
|
}
|
||||||
if (resp.status >= 400) {
|
if (resp.status >= 400) {
|
||||||
const payload = await resp.json().catch(() => ({}));
|
const payload = await resp.json().catch(() => ({}));
|
||||||
|
console.error("[createPost] API error:", payload);
|
||||||
throw new Error(payload?.error || `API responded with ${resp.status}`);
|
throw new Error(payload?.error || `API responded with ${resp.status}`);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn("Falling back to Supabase insert for post:", error);
|
console.warn("[createPost] API failed, falling back to direct Supabase (NO Discord sync):", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("[createPost] Using direct Supabase insert (Discord sync SKIPPED)");
|
||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
.from("community_posts")
|
.from("community_posts")
|
||||||
.insert(post)
|
.insert(post)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue