fix: replace crypto.randomUUID with HTTP-compatible alternative

crypto.randomUUID() is only available in secure contexts (HTTPS).
Since the app runs over HTTP in development, this caused a blank page
crash on the external links admin page.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Thomas Reitz 2026-03-10 11:08:21 +01:00
parent 1a87356048
commit 878f8be45c
2 changed files with 8 additions and 2 deletions

View file

@ -10,6 +10,7 @@ import {
import { ApiTags, ApiOperation } from '@nestjs/swagger'; import { ApiTags, ApiOperation } from '@nestjs/swagger';
import { Roles } from '../../common/decorators/roles.decorator'; import { Roles } from '../../common/decorators/roles.decorator';
import { RolesGuard } from '../../common/guards/roles.guard'; import { RolesGuard } from '../../common/guards/roles.guard';
import { randomUUID } from 'crypto';
import { RedisService } from '../../redis/redis.service'; import { RedisService } from '../../redis/redis.service';
/** /**
@ -84,7 +85,7 @@ export class SettingsController {
// Sortierung sicherstellen // Sortierung sicherstellen
const sorted = body.links.map((link, index) => ({ const sorted = body.links.map((link, index) => ({
id: link.id || crypto.randomUUID(), id: link.id || randomUUID(),
label: link.label.trim(), label: link.label.trim(),
url: link.url.trim(), url: link.url.trim(),
icon: link.icon || undefined, icon: link.icon || undefined,

View file

@ -2,6 +2,11 @@ import { useState, useEffect, useRef } from 'react';
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import api from '../api/client'; import api from '../api/client';
/** Einfache ID-Generierung (crypto.randomUUID ist nur ueber HTTPS verfuegbar) */
function generateId(): string {
return Date.now().toString(36) + Math.random().toString(36).slice(2, 10);
}
interface ExternalLink { interface ExternalLink {
id: string; id: string;
label: string; label: string;
@ -300,7 +305,7 @@ export function AdminExternalLinksPage() {
setLinks((prev) => [ setLinks((prev) => [
...prev, ...prev,
{ {
id: crypto.randomUUID(), id: generateId(),
label: '', label: '',
url: '', url: '',
icon: undefined, icon: undefined,