Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions app/api/generate/guest/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ export async function POST(req: NextRequest) {

const sessionId = `guest_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`

// Store a reference instead of full base64 data URIs (which bloat Supabase and cause timeouts)
const storableUrl = imageUrl.startsWith('data:') ? `generated:${genData.id || sessionId}` : imageUrl

// Log to Supabase (non-blocking)
if (SUPABASE_URL && SUPABASE_ANON) {
fetch(`${SUPABASE_URL}/rest/v1/guest_generations`, {
Expand All @@ -101,14 +104,14 @@ export async function POST(req: NextRequest) {
session_id: sessionId,
target_url: url,
style,
image_url: imageUrl,
image_url: storableUrl,
email: email || null,
created_at: new Date().toISOString(),
}),
}).catch(() => {})

// Also upsert into qron_demos for the gallery
if (imageUrl) {
// Also upsert into qron_demos for the gallery (skip base64 data URIs)
if (storableUrl && !storableUrl.startsWith('generated:')) {
fetch(`${SUPABASE_URL}/rest/v1/qron_demos`, {
method: 'POST',
headers: {
Expand Down
3 changes: 2 additions & 1 deletion app/api/generate/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ export async function POST(request: Request) {
)

const qronId = crypto.randomUUID()
const storableImageUrl = imageUrl.startsWith('data:') ? `generated:${qronId}` : imageUrl

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve retrievable image URL in qron_generations

When the worker returns a data URI, this stores image_url as generated:${qronId}, but there is no code path that resolves generated:* back to an actual image URL, while /api/qron/[id] returns qron.image_url directly (app/api/qron/[id]/route.ts, GET response). That means QRONs generated through /api/generate lose a renderable/downloadable image reference once reloaded from the database, so downstream consumers of persisted records receive a non-URL placeholder instead of an image.

Useful? React with 馃憤聽/ 馃憥.

await admin.from('qron_generations').insert({
id: qronId,
user_id: session.user.id,
image_url: imageUrl,
image_url: storableImageUrl,
destination_url: targetUrl,
prompt: finalPrompt,
preset_id: presetId || null,
Expand Down
Loading