Skip to content

Commit

Permalink
Fix POST request
Browse files Browse the repository at this point in the history
  • Loading branch information
Banakin committed Aug 22, 2020
1 parent 4c95dd4 commit 6d1b85d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions website/src/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -188,5 +188,5 @@ function downloadPack() {
document.querySelector('#fail-alert').style.display = 'block'; // Show fail alert
}
};
request.send(data);
request.send(JSON.stringify(data));
}

0 comments on commit 6d1b85d

Please sign in to comment.