Problem connecting WEB Core Appl to my XData serve

Hi Guys,

I've created a XData server on port 8213 called AP3. It uses native MSSQL connection and I have included the 2 tables in it as entities. The server runs and when entering http://localhost:8213/AP3/tb1 in the address line of the Edge browser, it shows me the contents of the table in json form.

I have then created a TMS WEB Aplication, with a TMSWEBGrid, TMSWEBNavigater, both connected to the TMSWEBDatasource1, which in turn is connected to XDataWebDataSet1, which has set entitysetname to tb1 (which I could chose as 1 of 2 in the dropdown list) and it has'its connection prop set to XDataWebConnection1. This has its url set to http://localhost:8213/AP3 AND I'm able to set the connected property... So it is setup correctly and it works.

The TMS WEB Core Application (called FAP3) compiles errorfree, but it opens the browser with


and an errormessage. xdataconnectionerror: Error connecting to XData Server
at http;//localhost:8000/FAP3.js [31696:13]

Why is it trying to access localhost at port 8000 when I have specified post 8213 in the URL ?

When manually changing the portno to 8213, I get an error: 404 so something tells me  the local application should run on localhost:8000.

NB! Portno 8000 is NOT reserved in http.sys and I have tried to replace localhost with

Anybody have an idea of what I'm doing wrong ?

Well, I've tested a lot more and have found a solution to the error and some more understanding of what's going on:

Firstly I needed to enable CORS, meaning in the server.pas I needed to unComment the Module.AddMiddleWare line relating to Cors in the StartServer procedure. That way the error disappeared

Secondly my understanding of the role of the http://Localhost:8000 has improved, and as long as I'm running my HTML / JS scripts directly from the Delphi Ide, it should stay like that.

Some comments for better understanding:

- Yes, CORS is usually the guilty here, specially when the web app is served from one port (8000) and the API it access is in another port (8123). If they were in the same port, CORS would not be needed.

- In errors like that, always check the browser console (F12 in Chrome, for example) to check for more detailed errors. It usually helps and provides more information about the cause of the error.

- There are two servers: one is the XData API, the other server just servers static files (html, js, css) that makes up the web application running in the browser. Localhost:8000 provides the web app to the browser, the browser loads and "runs" it, and then the app running in the browser connects to the API server (8123 port) to retrieve dynamic JSON data.

You may also use the new non-visual component  and add a middleware using the context-menu of that component. I personally prefer that solution to the code uncommenting. The latest XData videos show this approach and the current XData Server Wizard uses these components as well.