DMXzone App Connect Support Product Page

Solved

Remote Server Connect Action and CORS

Reported 20 Feb 2017 22:04:44
2
have this problem
20 Feb 2017 22:04:44 Michele - posted:
Hello
If I try to set a server connection with a remote server, I receive this popup dreamweaver error message:
"Server Action file "file:///Macintosh HD/.../dmxConnect/api/....php" cannot be found.


The url in the page is correct but your system not recognise the http parameter and search the connection in the local system:
<dmx-serverconnect id="serverconnect1" url="http://url/dmxConnect/api/....php" site="NAME"></dmx-serverconnect>


I'm searching to build an App with your new extension (to replace this old instruction www.dmxzone.com/go/22827/building-mobile-apps-with-html5-data-bindings-and-dmxzone-database-connector).

Is your new extension enable to build App (together with Server Connect)?
Thanks.
Regards,
Michele

Official Solution

Replied 02 Mar 2017 09:32:21
Hi Michele,

Yes due to browser security you have to deal with something like CORS
So to allow your Server Connect Actions to be accessible from other domain than the current one a special header is required that you will have to add on your server.

If you have Apache server the easiest way is to create a .htaccess file in /dmxConnect/api folder in your site and add to it:

Header set Access-Control-Allow-Origin "*"

For other servers see:

enable-cors.org/server.html

We will see if you can make such integrations of CORS more part of the Server Connect in the upcoming updates.

Greetings,
George

Replies

Replied 21 Feb 2017 07:43:01
21 Feb 2017 07:43:01 Teodor Kuduschiev replied:
Hello Michele,
we are going to check this issue and i will let you know what is wrong.
Replied 22 Feb 2017 16:26:31
22 Feb 2017 16:26:31 Michele - replied:
Hi Teodor,
is the problem fixed in the last version (released today)?

Thanks.
Replied 22 Feb 2017 16:43:13
22 Feb 2017 16:43:13 Teodor Kuduschiev replied:
Hello Michele,
The option to select action files from different site definition will be integrated in our next updates.
Replied 23 Feb 2017 13:31:16
23 Feb 2017 13:31:16 Michele - replied:
Ok, thanks.
I hope to see very soon this option because otherwise I can't continue working.

Sometimes, working with your extensions is really frustrating and it's difficult to schedule work activity.
Replied 26 Feb 2017 20:51:22
26 Feb 2017 20:51:22 George Petrov replied:
Hi Michele,

Have you setup correctly the Web URL from the Dreamweaver Site definition for used for your remote server?
It is under the site options / Servers / Edit / Basic settings - Web URL

If the right remote url site prefix is entered there everything should be resolved correctly.

Also make sure you pick the right site definition when you choose the server connect action.

Greetings,
George
Replied 27 Feb 2017 11:08:24
27 Feb 2017 11:08:24 Michele - replied:
Hi George,
I've setup correctly the site definition but the error is always the same (I'm using DW 2017.0.1 on OSX 10.12.3).

Could you (or someone in your team) refresh this video tutorial using your latest extensions?
www.dmxzone.com/go/22827/building-mobile-apps-with-html5-data-bindings-and-dmxzone-database-connector

I think it would be better to understand the exact/official procedure and avoid mistake/misunderstandings.

FYI, in the mac platform the icons "column", "value", "type" (e.g. in the dreamweaver popup source query builder) are missing.

Thanks!
Replied 27 Feb 2017 11:39:36
27 Feb 2017 11:39:36 Teodor Kuduschiev replied:
Hello Michele,
We will update this tutorial in the next couple of days.
Are you sure your remote site has its URL properly setup in the site definition? You just need to select it from:

in the server connect picker dialog.

The icons could be missing if HTML5 Data Bindings extension is not installed, as Server Connect is currently using them as a source - this will be improved in the next updates. For now just install Data Bindings, so the icons appear properly.
Replied 27 Feb 2017 21:52:29
27 Feb 2017 21:52:29 Michele - replied:
Hello Teodor,
I tried in every possible way but nothing, always the same error:

"Server Action file "file:///Macintosh HD/.../dmxConnect/api/....php" cannot be found.


I'll wait your tutorial.
Replied 28 Feb 2017 07:29:25
28 Feb 2017 07:29:25 Teodor Kuduschiev replied:
Hello Michele,
In the tutorial you will see the same as on the screenshot i posted above plus explanation, that your sites must be defined properly, with the site URL entered.
Please contact us in our live chat support today, so i can look into this issue directly with you.
Replied 28 Feb 2017 10:23:54
28 Feb 2017 10:23:54 Michele - replied:
Hello Teodor,
the site definitions are correct (also, to check I've used the same configuration from previous Apps created with the old HTML5 Data Bindings).

Also, I noticed that despite of the error, in the Dreamweaver Live view (2017.0.1) the records are visible but if I see the same page in the browser (or in the App installed on the smartphone), is empty.

For the moment I decided to stop the works on the App. I'll wait next updates.
Thanks for the support.

P.S. Please enable the function to insert "images" in the forum, I think it would be helpful to include screenshots without to load them from external resources.
Replied 28 Feb 2017 10:35:32
28 Feb 2017 10:35:32 Teodor Kuduschiev replied:
Please send me your screenshots at: or contact me in the live chat..
Replied 28 Feb 2017 13:42:24
28 Feb 2017 13:42:24 Teodor Kuduschiev replied:
Hi Michele, we've found the problem but there is not really a problem with the generated code. It is DW which is looking into the wrong place, and that's why the popup is showing, when you click the server connect component. This will be improved in the Server Connect and App Connect updates tomorrow.
Replied 28 Feb 2017 13:48:10
28 Feb 2017 13:48:10 Michele - replied:
Ok, thanks!
Replied 01 Mar 2017 21:48:49
01 Mar 2017 21:48:49 Michele - replied:
Hi Teodor,
I've installed the latest versions (that you have released today) and now the above error is fixed.

However, now I've a new problem... isn't possibile to load recordset from external source.
If I try to load the data from a query on a page and it isn't on the same server, the page is empty (not load nothing from the database/query).

With the old HTML 5 Bindings works good, with new App Connect not.

I'm working on a mac (latest os x version with "mamp pro" ) with Dreamweaver 2017.0.1.
My remote server (cloud server) has a OS Debian (last version).

I tried everything but the queries from cloud server (mysql) not load in the local (and I need about this behaviour because I'm building an App).

Thanks.

Replied 01 Mar 2017 22:54:00
01 Mar 2017 22:54:00 George Petrov replied:
Hi Michele,

Is the generated URL all ok? If you call it in the browser directly does it return data?

-George
Replied 02 Mar 2017 07:19:09
02 Mar 2017 07:19:09 Michele - replied:
Hi George,
in the browser's console I receive these two errors:

[Error] XMLHttpRequest cannot load http://url-remote.com/dmxConnect/api/News.php?. Origin http://url-local.it is not allowed by Access-Control-Allow-Origin.


[Error] Failed to load resource: the server responded with a status of 404 (Not Found)
http://url-local.it/dmxAppConnect/maps/dmxAppConnect.js.map


I've hidden the urls for my privacy in this post... url-remote.com (with the server behaviours) and url-local.it (my local App) obviously aren't the real values.

The same page created with the old HTML 5 Bindings extension, not generate these errors.
Replied 02 Mar 2017 09:32:21
02 Mar 2017 09:32:21 George Petrov replied:
Hi Michele,

Yes due to browser security you have to deal with something like CORS
So to allow your Server Connect Actions to be accessible from other domain than the current one a special header is required that you will have to add on your server.

If you have Apache server the easiest way is to create a .htaccess file in /dmxConnect/api folder in your site and add to it:

Header set Access-Control-Allow-Origin "*"

For other servers see:

enable-cors.org/server.html

We will see if you can make such integrations of CORS more part of the Server Connect in the upcoming updates.

Greetings,
George
Replied 02 Mar 2017 10:30:33
02 Mar 2017 10:30:33 Michele - replied:
Hi George,
I've insert the above Apache instruction and now it works.

Last thing... do you know if "Access-Control-Allow-Origin" could create some security ricks on my cloud server (is enable only in that specific domain)?

Thanks
Replied 02 Mar 2017 11:09:11
02 Mar 2017 11:09:11 George Petrov replied:
Hi Michele,

No this actually is for adding more security.
If you want to make it even more secure instead of * use only the domain that is allowed to call your server connect api calls.

See developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin

Greetings,
George
Replied 02 Mar 2017 11:12:01
02 Mar 2017 11:12:01 Michele - replied:
Ok!
Thanks for the support!

Reply to this topic