IPNS resolve using HTTP Request won't work

I am testing IPNS resolve using http POST request, testing codes as following:

var http_Req = new XMLHttpRequest();
http_Req.addEventListener(“load”, reqListener);
var url = “”;
http_Req.open(“POST”, url, true);

But got response error with 403 Forbidden.

Using CLI,
curl -X POST

However, curl command just shows as what I expect.

Any idea?

CORS configuration of go-ipfs. You need to allow the origin set by the browser. Check there actual request made by the browser, as it goes with original headers that your curl request does not set.

go-ipfs has some provisions to detect if requests come from a browser and only let’s them through when CORS origin is set accordingly.


Thanks for the reply. The CORS issue was OK after go-ipfs config setting.

Now, I intend to use fetch to send a HTTP request from the browser to go-ipfs at my desktop in order to resolve an IPNS peer id.

In browser end, I used the following test codes, but console log showed “undefined” CID.

I am wondering if ipns resolve can be done this way (fetch http request)?

Thank you for your help.

example codes:
go-ipfs version: 0.5.1

var url = ‘’;

function fetchCID(url){
const response = fetch(url, {
headers: {
‘content-type’: ‘application/x-www-form-urlencoded’
cache: ‘no-cache’,
credentials: ‘omit’,
method: ‘POST’,
mode: ‘cors’
(response) => {
if (response.ok){
// Examine the CID in the response
var json = response.json();
var CID = json.Path;
return (CID);
.catch(function(err) {
console.log(‘Fetch Error :’, err);