fix: use relative URLs for local media storage to fix CSP blocking

Media files were stored with absolute http://localhost:5555/... URLs,
which got blocked by the Content Security Policy when the app runs at
https://socialflow.fnancy.fr. Now stores relative /uploads/... paths
and resolves to absolute URLs only when needed by external APIs
(Facebook, FFmpeg internal service).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Sonnet 4.6 committed 2026-03-25 08:30:07 +01:00
1 parent 8f7f580b2f
commit b353fb6ded
4 files changed
+41 -22

No files matched your search

+5 -5
View File
@@ -8,7 +8,7 @@ import { storage } from '../storage';
import { freeSoundService, type MusicTrack } from '../services/freesound';
import { ffmpegService } from '../services/ffmpeg';
import { facebookService } from '../services/facebook';
import { minioService as cloudinaryService, buildMinioUrl } from '../services/minio';
import { minioService as cloudinaryService, buildMinioUrl, resolveInternalUrl } from '../services/minio';
import { openRouterService } from '../services/openrouter';
import { db } from '../db';
import { cloudinaryConfig } from '@shared/schema';
@@ -343,14 +343,14 @@ reelsRouter.post('/reels/preview', async (req: Request, res: Response) => {
try {
const config = await storage.getCloudinaryConfig();
if (config && config.logoPublicId) {
watermarkUrl = buildMinioUrl(config.cloudName, config.logoPublicId, config.publicUrl);
watermarkUrl = resolveInternalUrl(buildMinioUrl(config.cloudName, config.logoPublicId, config.publicUrl));
}
} catch (e) {
console.error('Error fetching watermark configuration', e);
}
// Traiter la vidéo via FFmpeg
const result = await ffmpegService.processReelFromUrl(media.originalUrl, {
const result = await ffmpegService.processReelFromUrl(resolveInternalUrl(media.originalUrl), {
text: overlayText,
musicUrl: finalMusicUrl,
ttsEnabled,
@@ -556,13 +556,13 @@ async function processReelBackground(
try {
const config = await storage.getCloudinaryConfig();
if (config && config.logoPublicId) {
watermarkUrl = buildMinioUrl(config.cloudName, config.logoPublicId, config.publicUrl);
watermarkUrl = resolveInternalUrl(buildMinioUrl(config.cloudName, config.logoPublicId, config.publicUrl));
}
} catch (e) {
console.error('Error fetching watermark configuration', e);
}
const ffmpegResult = await ffmpegService.processReelFromUrl(media.originalUrl, {
const ffmpegResult = await ffmpegService.processReelFromUrl(resolveInternalUrl(media.originalUrl), {
text: overlayText,
musicUrl: finalMusicUrl,
ttsEnabled,
+2 -2
View File
@@ -6,7 +6,7 @@ import { bundle } from "@remotion/bundler";
import { renderMedia, selectComposition } from "@remotion/renderer";
import { ffmpegService } from "../services/ffmpeg";
import { storage as dbStorage } from "../storage";
import { minioService as cloudinaryService, buildMinioUrl } from "../services/minio";
import { minioService as cloudinaryService, buildMinioUrl, resolvePublicUrl } from "../services/minio";
import { facebookService } from "../services/facebook";
import * as musicMetadata from "music-metadata";
@@ -319,7 +319,7 @@ remotionRouter.post("/publish", async (req, res) => {
if (!scheduledFor) {
console.log(`🚀 Publishing to ${page.pageName}...`);
const reelId = await facebookService.publishReel(page, cloudinaryResult.originalUrl, description || "");
const reelId = await facebookService.publishReel(page, resolvePublicUrl(cloudinaryResult.originalUrl), description || "");
await dbStorage.updateScheduledPost(scheduledPost.id, { publishedAt: new Date(), externalPostId: reelId });
results.push({ pageId, success: true, reelId });
} else {