mac-cain13 / xdebug-helper-for-chrome

Easily activate PHP debugging, profiling and tracing with this Xdebug Chrome extension
https://chrome.google.com/webstore/detail/eadndfjplgieldjbigjakmdgkmoaaaoc
307 stars 97 forks source link

Does it work with Single Page Applications? #62

Open morfin opened 8 years ago

morfin commented 8 years ago

Hi, This is my setup:

I have a SPA using AngularJS. This app interacts with an API Server which is located in a different domain. Data interaction is done using CORS mechanism.

When I first load the angular app, Xdebug Helper injects the XDEBUG_SESSION_START into the Cookie set by the SPA. Then I do an AJAX call (CORS) to my API Server app, and that server establish its own Cookie.

Here comes the problem: Xdebug Helper does not inject the XDEBUG_SESSION_START into this API Server cookie, where I actually need it.

I wonder if this happens not only when using CORS, but also with SPA's using JWT or OAuth Clients. Seems that Xdebug Helper only works with websites where frontend/backend reside in the same domain.

It would be nice if Xdebug Helper could inject the XDEBUG key into Cookies set by Cross-domain Ajax requests.

Any Idea?

mac-cain13 commented 8 years ago

Xdebug "just" sets a cookie on the domain of the website that is in the currently open tab. Setting it on another domain is possible, but would give a lot of UI clutter. If you know a solution that won't interfere with the simple use case a lot of people have it would be nice.

Just wondering; Maybe the new 1.5 release that has shipped today will fix our issue. You could try to go to a page on the domain you want to debug, turn debugging on and then work from your page on the other domain. Should probably work.

DaveTheCrane commented 8 years ago

Hi Mathijs, morfin,

First off, thanks Mathijs for writing & releasing the plugin for chrome - very neat.

I'm seeing the same problem that morfin described, on a similar setup (SPA on domain 1 talking to REST services on domain2 via CORS) - and I'm using version 1.5 of the xdebug helper plugin. The xdebug cookie isn't being sent to the REST service, which makes sense.

The front end app uses Angular, so I can probably get around it using something like this:

https://github.com/gonzalo123/ngXdebugger

but if there is anything I've missed in the plugin, please let me know, as it'd be preferable not to start adding to the client codebase.

Many thanks,

Dave

DaveTheCrane commented 8 years ago

My question is not urgent any more - I've worked around it by setting my php.ini with xdebug.remote_autostart=1, so that the cookie isn't required. (Answering my own question for the sake of anyone else on the internet who finds this issue.)

I read around cors/xdebug issues, I don't think there is a more elegant solution (including ngXdebugger, don't think that'd work). It isn't possible to set cookies on requests to other domains, AFAICT.

Regards, Dave