<p>Ardor versions prior to 2.1.0e rejected the OPTIONS Http method. This method is now enabled so the problem should be fixed.</p>

<p>It appears that Axios uses an OPTIONS Http request to check if CORS is enabled and since it was forbidden the response was a 403 response.</p>

CC BY-SA 4.0
2018-08-19T16:58:17.243Z
So it wasn't me! I assumed a different javascript module would work and tried with Jquery - that worked - Issue solved, thx
Mal Nemark
CC BY-SA 4.0
2018-08-19T10:59:00.663Z
2018-08-19T11:08:23.007Z
2018-08-19T11:08:23.007Z
lyaffe
<p>I am having issues with POST requests to the Ardor API. This code:</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;script src="https://unpkg.com/axios/dist/axios.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  function myFunction() {
      let nodeurl = "https://testardor.jelurida.com/nxt";
      const query = {
        recipient:'ARDOR-KZ3Y-4B97-6KF6-2V8WA',
        amountNQT:34,
        feeNQT:-1,
        deadline:15
      };
      axios.post(nodeurl, query)
      .then(function(response) {
        console.log(response.data);
        document.getElementById("demo").innerHTML = response.data;
      })
      .catch(function (error) {
        console.log(error.message);
      });
  }
  &lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;

&lt;h2&gt;Preflight request to CORS enabled Ardor Node fails&lt;/h2&gt;

&lt;p id="demo"&gt;The result should appear here&lt;/p&gt;
&lt;button type="button" onclick="myFunction()"&gt;Try it&lt;/button&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>fails during preflight. Chrome: </p>

<blockquote>
  <p>Failed to load <a href="http://localhost:26876/nxt" rel="nofollow noreferrer">http://localhost:26876/nxt</a>: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '<a href="http://127.0.0.1:3000" rel="nofollow noreferrer">http://127.0.0.1:3000</a>' is therefore not allowed access. The response had HTTP status code 403.</p>
</blockquote>

<p>What I understand is that it is not me who needs to send the 'Access-Control-Allow-Origin' header but the Ardor/NXT node.</p>

<p>Likely its just me not getting it. There are options around, you can change the content type, is that possible with NXT API? Is that something anybody had to do?</p>

<p>Its just failing for POST, GET works fine.</p>

<p>Thanks for any pointers in the right direction.</p>

CC BY-SA 4.0
2018-08-19T14:25:42.803Z
I'm voting to close this question as off-topic because This question should be asked on StackOverflow.
Tailer
<javascript><ardor><nxt-api>
Ardor API: Not able to use POST requests with Axios due to CORS issues
Mal Nemark
# Ardor API: Not able to use POST requests with Axios due to CORS issues

(Asked by: username_0 on 2018-08-19)

I am having issues with POST requests to the Ardor API. This code:

```
<!DOCTYPE html>
<html>
<head>
  <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  <script>
  function myFunction() {
      let nodeurl = "https://testardor.jelurida.com/nxt";
      const query = {
        recipient:'ARDOR-KZ3Y-4B97-6KF6-2V8WA',
        amountNQT:34,
        feeNQT:-1,
        deadline:15
      };
      axios.post(nodeurl, query)
      .then(function(response) {
        console.log(response.data);
        document.getElementById("demo").innerHTML = response.data;
      })
      .catch(function (error) {
        console.log(error.message);
      });
  }
  </script>
</head>

<body>

<h2>Preflight request to CORS enabled Ardor Node fails</h2>

<p id="demo">The result should appear here</p>
<button type="button" onclick="myFunction()">Try it</button>
</body>
</html>

```

fails during preflight. Chrome:

> Failed to load <http://localhost:26876/nxt>: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '<http://127.0.0.1:3000>' is therefore not allowed access. The response had HTTP status code 403.

What I understand is that it is not me who needs to send the 'Access-Control-Allow-Origin' header but the Ardor/NXT node.

Likely its just me not getting it. There are options around, you can change the content type, is that possible with NXT API? Is that something anybody had to do?

Its just failing for POST, GET works fine.

Thanks for any pointers in the right direction.

**Tags:** javascript, ardor, nxt-api

> **Comments:**
> **username_1**: I'm voting to close this question as off-topic because This question should be asked on StackOverflow.  

---

## 1 answers

### Answer by username_2 on 2018-08-19. Score: 0 | Accepted answer

Ardor versions prior to 2.1.0e rejected the OPTIONS Http method. This method is now enabled so the problem should be fixed.

It appears that Axios uses an OPTIONS Http request to check if CORS is enabled and since it was forbidden the response was a 403 response.

> **Comments:**
> **username_0**: So it wasn't me! I assumed a different javascript module would work and tried with Jquery - that worked - Issue solved, thx  

---

