Skip to content

Commit 8ac3c43

Browse files
committed
feat(frontend): add VITE_FORCE_SYNC to use POST /api/process in prod when needed
1 parent e1a7909 commit 8ac3c43

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

frontend/src/components/VideoUpload.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState, useCallback } from "react";
2-
import { API_BASE } from "@/lib/api";
2+
import { API_BASE, FORCE_SYNC } from "@/lib/api";
33
import { createProcessingJob, pollJob, fetchJobResult } from "@/lib/jobs";
44
import { Card, CardContent } from "@/components/ui/card";
55
import { Button } from "@/components/ui/button";
@@ -93,11 +93,12 @@ const VideoUpload = ({ onVideoProcessed }: VideoUploadProps) => {
9393

9494
// Prefer async job flow in production to avoid platform timeouts; keep sync in dev
9595
let blob: Blob;
96-
if (import.meta.env.DEV && !API_BASE) {
96+
if ((import.meta.env.DEV && !API_BASE) || FORCE_SYNC) {
9797
// local dev, use sync endpoint via Vite proxy
9898
const form = new FormData();
9999
form.append("video", uploadedVideo);
100-
const res = await fetch("/api/process", { method: "POST", body: form });
100+
const endpoint = FORCE_SYNC && API_BASE ? `${API_BASE}/api/process` : "/api/process";
101+
const res = await fetch(endpoint, { method: "POST", body: form });
101102
if (!res.ok) {
102103
const text = await res.text();
103104
throw new Error(text || `Request failed: ${res.status}`);

frontend/src/lib/api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ const DEFAULT_BACKEND = "https://sportiq-j4hv.onrender.com";
77
export const API_BASE = import.meta.env.PROD
88
? (import.meta.env.VITE_BACKEND_URL || DEFAULT_BACKEND)
99
: (import.meta.env.VITE_BACKEND_URL || "");
10+
11+
export const FORCE_SYNC = Boolean(import.meta.env.VITE_FORCE_SYNC);

0 commit comments

Comments
 (0)