From 6d1b85d19c2910108b8eb4a8a2fa2467002036d5 Mon Sep 17 00:00:00 2001 From: Brendan Leu Date: Sat, 22 Aug 2020 16:28:49 -0400 Subject: [PATCH] Fix POST request --- functions/index.js | 1 + website/src/js/script.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/functions/index.js b/functions/index.js index c8a2752a..30fdb702 100644 --- a/functions/index.js +++ b/functions/index.js @@ -41,6 +41,7 @@ exports.deletePacks = functions.pubsub.schedule('0 4 * * *').onRun(async (cxt) = // Create a zip file from file in storage ----- CLOUD FUNCTION ----- exports.makePack = functions.https.onRequest(async (req, res) => { res.set('Access-Control-Allow-Origin', process.env.NODE_ENV !== 'production' ? '*' : 'https://faithfultweaks.com'); + res.set('Access-Control-Allow-Headers', 'Content-Type'); res.set('Content-Type', 'application/json'); const bucket = admin.storage().bucket(); // Storage bucket diff --git a/website/src/js/script.js b/website/src/js/script.js index e901c676..282592be 100644 --- a/website/src/js/script.js +++ b/website/src/js/script.js @@ -173,7 +173,7 @@ function downloadPack() { }; request.open('POST', url, true); - // request.setRequestHeader("Content-Type", "application/json; charset=UTF-8"); + request.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); request.onreadystatechange = function() { if (this.readyState === 4 && this.status == 200) { // Request finished @@ -188,5 +188,5 @@ function downloadPack() { document.querySelector('#fail-alert').style.display = 'block'; // Show fail alert } }; - request.send(data); + request.send(JSON.stringify(data)); } \ No newline at end of file