fix some things for deploy to pro

This commit is contained in:
juancarlos.cavero 2025-12-19 21:20:10 +01:00
parent d9c85f6aed
commit a7ba51a2f1
5 changed files with 24 additions and 8 deletions

View file

@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<link rel="icon" type="image/png" href="/logo-openshorts.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OpenShorts.app</title>
</head>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 266 KiB

View file

@ -4,6 +4,7 @@ import KeyInput from './components/KeyInput';
import MediaInput from './components/MediaInput';
import ResultCard from './components/ResultCard';
import ProcessingAnimation from './components/ProcessingAnimation';
import { getApiUrl } from './config';
// Simple TikTok icon sine Lucide might not have it or it varies
const TikTokIcon = ({ size = 16, className = "" }) => (
@ -85,7 +86,7 @@ const UserProfileSelector = ({ profiles, selectedUserId, onSelect }) => {
// Mock polling function
const pollJob = async (jobId) => {
const res = await fetch(`/api/status/${jobId}`);
const res = await fetch(getApiUrl(`/api/status/${jobId}`));
if (!res.ok) throw new Error('Status check failed');
return res.json();
};
@ -157,7 +158,7 @@ function App() {
const fetchUserProfiles = async () => {
if (!uploadPostKey) return;
try {
const res = await fetch('/api/social/user', {
const res = await fetch(getApiUrl('/api/social/user'), {
headers: { 'X-Upload-Post-Key': uploadPostKey }
});
if (!res.ok) throw new Error("Failed to fetch");
@ -197,7 +198,7 @@ function App() {
// Content-Type is auto-set for FormData
}
const res = await fetch('/api/process', {
const res = await fetch(getApiUrl('/api/process'), {
method: 'POST',
headers: data.type === 'url' ? headers : { 'X-Gemini-Key': apiKey },
body

View file

@ -1,5 +1,6 @@
import React, { useState } from 'react';
import { Download, Share2, Instagram, Youtube, Video, CheckCircle, AlertCircle, X, Loader2 } from 'lucide-react';
import { getApiUrl } from '../config';
export default function ResultCard({ clip, index, jobId, uploadPostKey, uploadUserId }) {
const [showModal, setShowModal] = useState(false);
@ -27,7 +28,7 @@ export default function ResultCard({ clip, index, jobId, uploadPostKey, uploadUs
setPostResult(null);
try {
const res = await fetch('/api/social/post', {
const res = await fetch(getApiUrl('/api/social/post'), {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
@ -64,19 +65,21 @@ export default function ResultCard({ clip, index, jobId, uploadPostKey, uploadUs
}
};
const videoUrl = getApiUrl(clip.video_url);
return (
<div className="glass-panel overflow-hidden animate-[fadeIn_0.5s_ease-out]" style={{ animationDelay: `${index * 0.1}s` }}>
<div className="grid md:grid-cols-2 gap-0">
<div className="bg-black/50 aspect-[9/16] relative group">
<video
src={clip.video_url}
src={videoUrl}
controls
className="w-full h-full object-contain"
loop
/>
<div className="absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity">
<a
href={clip.video_url}
href={videoUrl}
download
className="p-2 bg-black/60 backdrop-blur rounded-lg text-white hover:bg-black/80 inline-flex"
>
@ -131,7 +134,7 @@ export default function ResultCard({ clip, index, jobId, uploadPostKey, uploadUs
<Share2 size={16} /> Post to Socials
</button>
<a
href={clip.video_url}
href={videoUrl}
download
className="flex-1 py-2 bg-primary/10 hover:bg-primary/20 text-primary rounded-lg text-sm font-medium transition-colors flex items-center justify-center gap-2"
>

12
dashboard/src/config.js Normal file
View file

@ -0,0 +1,12 @@
// Configuration for API endpoints
// If VITE_API_URL is set (e.g. in production), use it.
// Otherwise, default to empty string which means relative paths (proxied in dev).
export const API_BASE_URL = import.meta.env.VITE_API_URL || '';
export const getApiUrl = (path) => {
if (path.startsWith('http')) return path;
// Ensure path starts with / if not present
const normalizedPath = path.startsWith('/') ? path : `/${path}`;
return `${API_BASE_URL}${normalizedPath}`;
};