Firebase Cloud Functions + Hosting JavaScript
Ein JavaScript-Snippet für Firebase Cloud Functions + Hosting, das Anfragen an /pixel.gif mit dem leeren GIF beantwortet, das einmal beim Start dekodiert wird.
Firebase Cloud Functions + Hosting JavaScript
// functions/index.js - and in firebase.json:
// "hosting": { "rewrites": [{ "source": "/pixel.gif", "function": { "functionId": "pixel" } }] }
import { onRequest } from 'firebase-functions/https';
const GIF = Buffer.from('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==', 'base64');
export const pixel = onRequest((req, res) => {
res.set('Cache-Control', 'no-store').type('gif').send(GIF);
});
Wir haben dieses Snippet kompiliert oder seine Typen geprüft.
Prüfen
curl -sI http://localhost:8080/pixel.gif
Offizielle Website: Firebase Cloud Functions + Hosting