Lahat ng language at framework
Firebase Cloud Functions + Hosting JavaScript
Isang JavaScript snippet para sa Firebase Cloud Functions + Hosting na sumasagot sa mga request sa /pixel.gif gamit ang empty GIF, na isang beses lang dine-decode sa startup.
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);
});
Kinompile o tinype-check namin ang snippet na ito.
Suriin
curl -sI http://localhost:8080/pixel.gif
Opisyal na site: Firebase Cloud Functions + Hosting