Implement missing sample data loading and one-time use security

- Fix UI to load server-hosted sample data at startup as per specification
- Add one-time use security: server clears sample data after retrieval
- Ensure React app periodically checks for new sample data availability
- Remove complex same-origin protection in favor of simpler one-time use model
- Improve data security by preventing data persistence after consumption
This commit is contained in:
2026-01-23 06:15:21 +01:00
parent 766ff96137
commit abc1cef7c2
3 changed files with 24 additions and 10 deletions

View File

@@ -54,22 +54,30 @@ function App() {
localStorage.setItem('theme', theme);
}, [theme]);
// API polling for state changes
// API polling for state changes and initial sample data load
useEffect(() => {
// Initial state load
const loadInitialState = async () => {
// Initial load: get both state and sample data
const loadInitialData = async () => {
try {
const response = await fetch('/api/v1/state');
if (response.ok) {
const data = await response.json();
setCurrentStateGuid(data.state);
// Load sample data first
const sampleResponse = await fetch('/api/v1/sample');
if (sampleResponse.ok) {
const sampleData = await sampleResponse.json();
setJsonData(JSON.stringify(sampleData, null, 2));
}
// Then load state GUID
const stateResponse = await fetch('/api/v1/state');
if (stateResponse.ok) {
const stateData = await stateResponse.json();
setCurrentStateGuid(stateData.state);
}
} catch (error) {
console.debug('API not available:', error);
}
};
loadInitialState();
loadInitialData();
// Poll for state changes every 3 seconds
const interval = setInterval(async () => {