Skip to content

Commit 85b0977

Browse files
RustyRoryclaude
andcommitted
Fix crypto.randomUUID not available over HTTP
Replace with a custom generateId() that works without HTTPS Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 4fab191 commit 85b0977

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

lucky7-app/frontend/src/app/components/GameScreen.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use client';
22

33
import { useState, useEffect } from 'react';
4+
import { generateId } from '@/lib/utils';
45
import { Button } from '@/components/ui/button';
56
import { Input } from '@/components/ui/input';
67
import { Card, CardContent, CardFooter, CardHeader, CardTitle } from '@/components/ui/card';
@@ -345,7 +346,7 @@ export default function GameScreen({ players: initialPlayers, rules, onEnd }: Ga
345346
setManageError('Ce pseudo est déjà dans la partie.');
346347
return;
347348
}
348-
setPlayers(prev => [...prev, { id: crypto.randomUUID(), name }]);
349+
setPlayers(prev => [...prev, { id: generateId(), name }]);
349350
setManageInput('');
350351
}
351352

lucky7-app/frontend/src/app/components/SingleDeviceLobby.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Card, CardContent, CardFooter, CardHeader, CardTitle } from '@/componen
77
import { Badge } from '@/components/ui/badge';
88
import { Separator } from '@/components/ui/separator';
99
import GameScreen, { type RulesConfig } from './GameScreen';
10+
import { generateId } from '@/lib/utils';
1011

1112
interface Player {
1213
id: string;
@@ -81,7 +82,7 @@ export default function SingleDeviceLobby({ onBack }: SingleDeviceLobbyProps) {
8182
setError('Ce pseudo est déjà dans la partie.');
8283
return;
8384
}
84-
setPlayers((prev) => [...prev, { id: crypto.randomUUID(), name }]);
85+
setPlayers((prev) => [...prev, { id: generateId(), name }]);
8586
setInput('');
8687
}
8788

lucky7-app/frontend/src/lib/utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ import { twMerge } from "tailwind-merge"
44
export function cn(...inputs: ClassValue[]) {
55
return twMerge(clsx(inputs))
66
}
7+
8+
// Fonctionne en HTTP et HTTPS (crypto.randomUUID n'est dispo qu'en HTTPS)
9+
export function generateId(): string {
10+
return Date.now().toString(36) + Math.random().toString(36).slice(2, 9);
11+
}

0 commit comments

Comments
 (0)