# POST request from addon page to server is empty

**URL:** <https://discourse.mozilla.org/t/post-request-from-addon-page-to-server-is-empty/28260>\
**Category:** Development\
**Created:** [May 2, 2018, 6:24pm UTC](https://discourse.mozilla.org/t/post-request-from-addon-page-to-server-is-empty/28260 "2018-05-02T18:24:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ea.zhilina](https://avatars.discourse-cdn.com/v4/letter/e/e68b1a/32.png) [@ea.zhilina](https://discourse.mozilla.org/u/ea.zhilina)\
**Post date:** [May 2, 2018, 6:24pm UTC](https://discourse.mozilla.org/t/post-request-from-addon-page-to-server-is-empty/28260/1 "2018-05-02T18:24:55Z")

</div>

Hello! We have developed an add-on, with it’s own page, where there is an html form with “action”=“address of our site” and “method”=“post”. In the latest versions of the firefox, it stops to work. The form submits an empty request. What can be done to improve the situation? Thank you.

---

<div class="post-metadata">

**Author:** ![NilkasG](https://avatars.discourse-cdn.com/v4/letter/n/0ea827/32.png) [@NilkasG](https://discourse.mozilla.org/u/NilkasG)\
**Post date:** [May 3, 2018, 12:21am UTC](https://discourse.mozilla.org/t/post-request-from-addon-page-to-server-is-empty/28260/2 "2018-05-03T00:21:02Z")

</div>

That is hardly enough information to give you an answer.

---

<div class="post-metadata">

**Author:** ![ea.zhilina](https://avatars.discourse-cdn.com/v4/letter/e/e68b1a/32.png) [@ea.zhilina](https://discourse.mozilla.org/u/ea.zhilina)\
**Post date:** [May 3, 2018, 5:13am UTC](https://discourse.mozilla.org/t/post-request-from-addon-page-to-server-is-empty/28260/3 "2018-05-03T05:13:50Z")

</div>

Hi! There is an example. To show the problem we take an example [https://github.com/mdn/webextensions-examples/tree/master/open-my-page-button](https://github.com/mdn/webextensions-examples/tree/master/open-my-page-button) and place the html form on it page. Here is zip with example [https://yadi.sk/d/YEbnHvhp3VCzdF](https://yadi.sk/d/YEbnHvhp3VCzdF) .  
Just use your own action address for test.

---

<div class="post-metadata">

**Author:** ![NilkasG](https://avatars.discourse-cdn.com/v4/letter/n/0ea827/32.png) [@NilkasG](https://discourse.mozilla.org/u/NilkasG)\
**Post date:** [May 4, 2018, 4:10am UTC](https://discourse.mozilla.org/t/post-request-from-addon-page-to-server-is-empty/28260/4 "2018-05-04T04:10:31Z")

</div>

The first thing I would try is to add a host permission for the target, otherwise your empty request might just be the preflight request.

---

<div class="post-metadata">

**Author:** ![ea.zhilina](https://avatars.discourse-cdn.com/v4/letter/e/e68b1a/32.png) [@ea.zhilina](https://discourse.mozilla.org/u/ea.zhilina)\
**Post date:** [May 9, 2018, 5:08pm UTC](https://discourse.mozilla.org/t/post-request-from-addon-page-to-server-is-empty/28260/5 "2018-05-09T17:08:14Z")

</div>

Hello! To add a host permission is not helping. And there is one more detail. Html form with method=“post” sending as empty GET request.  
$\_SERVER[‘REQUEST\_METHOD’]==‘GET’

---

<div class="post-metadata">

**Author:** ![NilkasG](https://avatars.discourse-cdn.com/v4/letter/n/0ea827/32.png) [@NilkasG](https://discourse.mozilla.org/u/NilkasG)\
**Post date:** [May 9, 2018, 5:55pm UTC](https://discourse.mozilla.org/t/post-request-from-addon-page-to-server-is-empty/28260/6 "2018-05-09T17:55:43Z")

</div>

I think this may be related to this discussion I just remembered:

> [@WebExtension form POST sent as GET from window created with chrome.windows.create](https://discourse.mozilla.org/t/webextension-form-post-sent-as-get-from-window-created-with-chrome-windows-create/14181):
>
> Hi, I have a WebExtension that uses chrome.windows.create() to open a window that displays a locally packaged HTML file. In the locally packaged HTML file I have an HTML that has method=“post”. The action posts to an external URL / another site which then processes the data and displays a small UI. When I load in my WebExtension from my every-day FF profile using “Load temporary add-on” everything works great. The signed copy of my extension installed in my users’ browsers also works great…

The conclusion there was that it is a bug, which still hasn’t been fixed.

Here are some different approaches that might work:

- don’t just have a form POSTing to the target host, embed an iframe with that form from that host instead (assuming you control that server)
- use GET (just keep some security aspects in mind)
- use `XHR` or `fetch` to POST (in a `submit` handler, grab the `formdata` and programmatically post it, then handle the response)
