Generate prayer ID on server to fix crypto.randomUUID browser compat

Older browsers (and non-HTTPS contexts) don't have crypto.randomUUID.
Move ID generation to the server using Node's built-in crypto module.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DReRqHxSYuVfCzTzQGD9hZ
This commit is contained in:
Claude committed 2026-07-18 17:18:12 +00:00
1 parent a27b35191d
commit bdf27b8b99
2 files changed
+3 -3

No files matched your search

+2 -1
View File
@@ -2,6 +2,7 @@ const express = require('express');
const cors = require('cors');
const fs = require('fs');
const path = require('path');
const { randomUUID } = require('crypto');
const app = express();
const DATA_DIR = process.env.DATA_DIR || path.join(__dirname, 'data');
@@ -50,7 +51,7 @@ app.get('/api/prayers', (req, res) => {
app.post('/api/prayers', (req, res) => {
try {
const prayers = readPrayers();
const prayer = req.body;
const prayer = { id: randomUUID(), ...req.body };
prayers.unshift(prayer);
writePrayers(prayers);
res.status(201).json(prayer);
+1 -2
View File
@@ -25,8 +25,7 @@ export function usePrayers() {
}, []);
const addPrayer = useCallback(async (request: string, tags: string[]) => {
const prayer: Prayer = {
id: crypto.randomUUID(),
const prayer = {
request,
answer: '',
status: 'active',