Fix coin tracker data persistence issue

- Updated API URLs from localhost:3000 to localhost:3001 in script.js
- Added CORS headers to server.js to enable cross-origin requests
- Changed server port from 3000 to 3001 to avoid port conflicts
- Updated CSP in index.html to allow connections to localhost:3001
- Coin tracker entries now persist across page refreshes
This commit is contained in:
root
2025-09-19 13:29:59 +02:00
parent c0bf7413de
commit 4803ae2d18
3 changed files with 79 additions and 49 deletions

View File

@@ -5,12 +5,20 @@ const fs = require('fs');
const path = require('path');
const cron = require('node-cron');
const app = express();
const port = 3000;
const port = 3001;
// Serve static files from the current directory
app.use(express.static(__dirname));
app.use(bodyParser.json());
// Add CORS middleware
app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
next();
});
// Create backups directory if it doesn't exist
const backupDir = path.join(__dirname, 'backups');
if (!fs.existsSync(backupDir)) {