superdesk / web-publisher

Superdesk Publisher - the next generation publishing platform for journalists and newsrooms.
GNU Affero General Public License v3.0
96 stars 55 forks source link

"No 'Access-Control-Allow-Origin' header is present on the requested resource." Despite correctly setting CORS? #562

Closed CaerphillyMediaLtd closed 6 years ago

CaerphillyMediaLtd commented 6 years ago

When I go to the Publisher section of Superdesk I keep getting:

Failed to load http://18.217.179.35/api/v1/auth/superdesk/: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://52.15.65.25' is therefore not allowed access. The response had HTTP status code 401.

My parameters.yml file has:

allow_origin_cors: '*'

I'm not sure why it's not working.

CaerphillyMediaLtd commented 6 years ago

Ahh, that was just because I hadn't cleared the cache. I do have another issue however.

I keep getting a 401 unauthorized error when trying to connect to publisher, and I get a php error in the nginx log:

2018/06/26 14:04:26 [error] 6318#6318: *15 FastCGI sent in stderr: "PHP message: PHP Warning: Invalid argument supplied for foreach() in /var/www/publisher/src/SWP/Bundle/CoreBundle/Controller/AuthController.php on line 104" while reading response header from upstream, client: 185.38.246.x, server: , request: "POST /api/v1/auth/superdesk/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "18.220.196.xx", referrer: "http://52.15.65.xx/"

CaerphillyMediaLtd commented 6 years ago

This is a bug. During the interactive creation of the parameters.yml file if you only enter a single superdesk server IP it puts it there as a string instead of an array. But the PHP always assumes it's an array there so it runs into issues if it's not. I've created a fix and will make a pull request shortly.