Firebase Cloud Functions + Hosting JavaScript
/pixel.gif కు వచ్చే రిక్వెస్ట్లకు empty GIF తో జవాబిచ్చే, Firebase Cloud Functions + Hosting కోసం JavaScript స్నిపెట్. GIF స్టార్టప్లో ఒక్కసారే డీకోడ్ అవుతుంది.
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);
});
మేము ఈ స్నిపెట్ను కంపైల్ లేదా టైప్-చెక్ చేశాం.
చెక్ చేయండి
curl -sI http://localhost:8080/pixel.gif
అధికారిక సైట్: Firebase Cloud Functions + Hosting