-
-
Save levidurfee/400c84ae153775e6d6432c665efca960 to your computer and use it in GitHub Desktop.
Firebase Cloud Function for Content Security Policy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const functions = require('firebase-functions'); | |
const admin = require('firebase-admin'); | |
admin.initializeApp(functions.config().firebase); | |
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: ${ref.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