ಎಲ್ಲಾ ಭಾಷೆಗಳು ಮತ್ತು ಫ್ರೇಮ್ವರ್ಕ್ಗಳು
Firebase Cloud Functions + Hosting JavaScript
/pixel.gif ಗೆ ಬರುವ ವಿನಂತಿಗಳಿಗೆ ಖಾಲಿ 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