Skip to content

Commit

Permalink
add cors
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanBonsignori committed Mar 11, 2024
1 parent 7a1d4d1 commit 4071eb3
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@ async function createNewDoc(blog) {
db.collection('blog').doc(blog).set({ likes: 0 });
}

exports.getBlog = onRequest(async (req, res) => {
const cors = [
'https://ethanbon.com',
'https://www.ethanbon.com',
'http://ethanbon.com',
'http://www.ethanbon.com',
'https://ethanbo.co',
'https://www.ethanbo.co',
'http://ethanbo.co',
'http://www.ethanbo.co',
];

exports.getBlog = onRequest({ cors }, async (req, res) => {
const blog = req.params[0];
db.collection('blog')
.doc(blog)
Expand All @@ -29,7 +40,7 @@ exports.getBlog = onRequest(async (req, res) => {
});
});

exports.likeBlog = onRequest(async (req, res) => {
exports.likeBlog = onRequest({ cors }, async (req, res) => {
const blog = req.params[0];
db.collection('blog')
.doc(blog)
Expand Down

0 comments on commit 4071eb3

Please sign in to comment.