eWon DataMailbox - Cross-Domain Request

ewon
flexy
datamail

#1

Hello all,

We are using a Flexy and DataMailbox service, and we have a company WebApp that is trying to retrieve the JSON data from DataMailbox but it is failing because of CORS (Cross-Origin Resource Sharing) which is implemented for security purposes in modern browsers.

[IMAGE REMOVED FOR SECURITY REASONS]

I would like to know if there is any work around this issue.

Thanks, regards.

Lucas Ochoa
Liquid Consulting


#4

@lucasLC

This should not be happening here. I was able to directly use your API call with no issues.

Can you provide me with a screenshot of your headers in Chrome or Firefox when you issue the request?


#5

We are using an AJAX request, but i have no headers set up for the request.

// Ajax requests

request = $.ajax({
method: “GET”,
url: “https://data.talk2m.com/getewons?t2maccount=account&t2musername=username&t2mpassword=password&t2mdevid=1234”,
});

request.success(function(data) {
callfunction;
});

When the request is made this is the error i get from Chrome in this case:

Failed to load https://data.talk2m.com/getewons?t2maccount=account&t2musername=username&t2mpassword=password&t2mdevid=1234: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://linux-console-lucasou89.c9users.io:8080’ is therefore not allowed access.

Thanks, regards.

Lucas Ochoa


#6

@lucasLC

The issue actually appears to be with the way your Cloud9 Apache server is running. I used the below AJAX request running on my host inside of an XAMPP localhost and it worked just fine.


Ajax Request

$.ajax({
   url: 'https://data.talk2m.com/getewons',
   method: 'POST',
   data: {
      't2maccount':'account',
      't2musername': 'user',
      't2mpassword': 'password',
      't2mdevid': 'devid'
    },
    success: function(response) {
       console.log(response);
    },
    error: function(response) {
       console.log(response);
    }
});

The console.log returned:

response

Have you tried on a live server as opposed to the Cloud9 dev environment?


#7

Hello Jordan,

I tried after uploading the app to another host in heroku, same thing, still showing CORS compatibility error.

I will keep looking to see if i have something wrong on my side.

Thanks, regards.

Lucas Ochoa


#9

@lucasLC

My apologies, I have confirmed that CORS is in fact restricted on the Data Mailbox server. Any requests to this server should be handled by your backend. Apologies on my earlier confusion, it was working on my end because I use a CORS override plugin in my test environment and had errantly left it enabled.

Development is exploring permitting this feature however at this time it is not allowed.


#10

Thanks a lot Jordan for your help. I will probably set up a program on our server to periodically request data from DataMailbox and save it in the database that our webApp has access to. In that way we will be able to have the data we need.

Thanks, again.