# Публикация через API Discourse и Firebase (Cloud Functions)

**URL:** <https://meta.discourse.org/t/posting-via-discourse-api-and-firebase-cloud-functions/225823>\
**Category:** Product Support\
**Created:** [01.Май.2022 19:14:59 UTC](https://meta.discourse.org/t/posting-via-discourse-api-and-firebase-cloud-functions/225823 "2022-05-01T19:14:59Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![kirupa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kirupa/32/374711_2.png) [@kirupa](https://meta.discourse.org/u/kirupa)\
**Post date:** [02.Май.2022 18:55:57 UTC](https://meta.discourse.org/t/posting-via-discourse-api-and-firebase-cloud-functions/225823/2 "2022-05-02T18:55:57Z")

</div>

Мне удалось исправить это, и я делюсь своим обновлённым кодом на случай, если кто-то ещё столкнётся с этой проблемой:

```plaintext
exports.sendfeedback = onRequest({ cors: "https://www.kirupa.com" }, (req, res) => {
  let myHeaders = new fetch.Headers();
  myHeaders.append("Api-Key", "removed");
  myHeaders.append("Api-Username", "kirupaBot");
  myHeaders.append("Content-Type", 'application/json');

  let requestOptions = {
    method: 'POST',
    headers: myHeaders,
    body: JSON.stringify({
      "raw": req.query.raw,
      "title": req.query.title
    })
  };

  fetch("https://forum.kirupa.com/posts.json", requestOptions)
    .then(r => r.json())
    .then(result => res.send(result))
    .catch(error => res.send(error));
});

```

---

_[View the full topic](https://meta.discourse.org/t/posting-via-discourse-api-and-firebase-cloud-functions/225823)._
