Supervisor / supervisor

Supervisor process control system for Unix (supervisord)
http://supervisord.org
Other
8.45k stars 1.24k forks source link

Enabling Cross-Origin Resource Sharing (CORS) for XML-RPC #1076

Open gabrielpra1 opened 6 years ago

gabrielpra1 commented 6 years ago

I'm trying to use an AngularJS application to communicate with Supervisord via the XML-RPC interface, but I'm getting the following error:

Firefox:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:9001/rpc2. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

Chrome:

Failed to load http://localhost:9001/rpc2: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. The response had HTTP status code 400.

I've had success when using a NodeJS server to communicate with Supervisord, so I know the XML-RPC is configured well, the problem really seems to be making those request from the browser.

So, is there any way to enable CORS from the Supervisord server? I couldn't find anything about that in the Configuration File page of the docs.

TimurDela commented 3 years ago

Any news on this issue? Or is there any way around to access the XML-RPC API from a custom web-app?

gabrielpra1 commented 3 years ago

Hey @TimurDela, I didn't find any way to configure this, so what I ended up doing was creating a backend API (where I could configure CORS as I wanted) that functions as a wrapper around the supervisor's API.