Firebase Cloud Functions + Hosting JavaScript
Firebase Cloud Functions + Hosting için, /pixel.gif isteklerine başlangıçta bir kez çözülen boş GIF ile yanıt veren bir JavaScript örneği.
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);
});
Bu örneği derledik veya tip denetiminden geçirdik.
Kontrol et
curl -sI http://localhost:8080/pixel.gif
Resmî site: Firebase Cloud Functions + Hosting