Skip to content

Instantly share code, notes, and snippets.

@levidurfee levidurfee/index.js Secret
Created May 7, 2019

What would you like to do?
Firebase Cloud Function for Content Security Policy
const functions = require('firebase-functions');
const admin = require('firebase-admin');
exports.cspReport = functions.https.onRequest((request, response) => {
const report = JSON.parse(request.body.toString('utf8'));
const writeResult = admin.firestore().collection('reports').add(report);
writeResult.then((ref) => {
return response.json({result: `Message with ID: ${} added.`});
}).catch((err) => {
return response.json({result: `Failed. ` + err });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.