From b3f4ee8a2384046f974819d8660243a820082929 Mon Sep 17 00:00:00 2001 From: mario4tier Date: Thu, 29 Aug 2024 14:18:47 -0400 Subject: [PATCH] Add empty favicon.ico to backend CDN server --- backend/cache/dist/server.js | 9 ++++++++- backend/cache/src/server.ts | 23 ++++++++++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/backend/cache/dist/server.js b/backend/cache/dist/server.js index 9ab31d1..17422ff 100644 --- a/backend/cache/dist/server.js +++ b/backend/cache/dist/server.js @@ -5,8 +5,15 @@ import { router } from './router.js'; const port = process.env.PORT || 3000; const app = express(); app.use(cors()); +// Serve a blank and transparent favicon.ico +const favicon = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH5QYQFhQnJ5sZJQAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAANSURBVDjLY2AYBaNgFIwEAGIMCk0pDgAAAABJRU5ErkJggg==', 'base64'); +app.get('/favicon.ico', (req, res) => { + res.setHeader('Content-Type', 'image/png'); + res.setHeader('Cache-Control', 'public, max-age=86400'); // TODO Increase after testing + res.send(favicon); +}); app.get('/', (req, res) => { - res.set('Cache-Control', 'public, max-age=300'); + res.set('Cache-Control', 'public, max-age=86400'); // Cache 1 day res.send('CDN is responding.

Access your own blob with https://cdn.suiftly.io/blob/<your_blob_id>'); }); app.use('/blob', router); diff --git a/backend/cache/src/server.ts b/backend/cache/src/server.ts index 4168146..3b38fbe 100644 --- a/backend/cache/src/server.ts +++ b/backend/cache/src/server.ts @@ -9,15 +9,28 @@ const port = process.env.PORT || 3000; const app = express(); app.use(cors()); + +// Serve a blank and transparent favicon.ico +const favicon = Buffer.from( + 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH5QYQFhQnJ5sZJQAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAANSURBVDjLY2AYBaNgFIwEAGIMCk0pDgAAAABJRU5ErkJggg==', + 'base64', +); + +app.get('/favicon.ico', (req, res) => { + res.setHeader('Content-Type', 'image/png'); + res.setHeader('Cache-Control', 'public, max-age=86400'); // TODO Increase after testing + res.send(favicon); +}); + app.get('/', (req, res) => { - res.set('Cache-Control', 'public, max-age=300'); - res.send( - 'CDN is responding.

Access your own blob with https://cdn.suiftly.io/blob/<your_blob_id>' - ); + res.set('Cache-Control', 'public, max-age=86400'); // Cache 1 day + res.send( + 'CDN is responding.

Access your own blob with https://cdn.suiftly.io/blob/<your_blob_id>', + ); }); app.use('/blob', router); app.listen(port, () => { - console.log(`App listening on port: ${port}`); + console.log(`App listening on port: ${port}`); });