Skip to content

Commit

Permalink
Add empty favicon.ico to backend CDN server
Browse files Browse the repository at this point in the history
  • Loading branch information
mario4tier committed Aug 29, 2024
1 parent 336badc commit b3f4ee8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
9 changes: 8 additions & 1 deletion backend/cache/dist/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br><br> Access your own blob with <b>https://cdn.suiftly.io/blob/<i>&ltyour_blob_id&gt</i></b>');
});
app.use('/blob', router);
Expand Down
23 changes: 18 additions & 5 deletions backend/cache/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br><br> Access your own blob with <b>https://cdn.suiftly.io/blob/<i>&ltyour_blob_id&gt</i></b>'
);
res.set('Cache-Control', 'public, max-age=86400'); // Cache 1 day
res.send(
'CDN is responding.<br><br> Access your own blob with <b>https://cdn.suiftly.io/blob/<i>&ltyour_blob_id&gt</i></b>',
);
});

app.use('/blob', router);

app.listen(port, () => {
console.log(`App listening on port: ${port}`);
console.log(`App listening on port: ${port}`);
});

0 comments on commit b3f4ee8

Please sign in to comment.