We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

REST api together with MVC web app - how to consume by other app

Hello

My problem is as follows: I have a regular web application, single module, with simple ACL and so on. The other is also a web application, but with some API-like behaviors in that it (should) provides some data in form of JSON to remote applications. I am testing everything on localhost. I have virtual hosts, one is webapp1.testapp.com and the other is webapp2.testapp.com for example.

Right now there is a controller ApiController with a simple json returning method. Works perfectly in the webapp2.testapp.com subdomain. However, as soon as i try the same thing in a browser window where the other app is running (webapp1), the same request returns nothing except the frontpage HTML of webapp2. I have debug points all over the application, but none of them are getting hit, when i fire the request in another subdomain.

Now i did have problems with Cross-origin resource sharing before, but it doesn't show it to be an issue anymore (or maybe it is?). Basically it no longer shows troubles with headers. However i did notice that there is no xdebug cookie when im in webapp1 domain so no wonder it is not debugging. 'm using a Firefox addon for debugging and it is on on both browser tabs, but it will not fire in a different domain.

For the sake of testing i turned off ACL in both apps so at least that should'nt interfere.
If any of you have experience with this, please help. I'm kind of lost and



8.7k
Accepted
answer

Update: the question was dumb. I found the issue. It was nothing to do with subdomains, but rather the fact i did not take into account that the BaseController class actually forwarded (when not logged in) always to front page. Will make a different base controller for api controllers.