2

I keep getting CORS error while using the Docker remote API.

As the Docker documentation mentions, I did set the flag:

"api-cors-header" : "*",

I still do not see the header Access-Control-Allow-Origin: * set on the response headers.

I am using Docker 1.13 experimental.

  • Docker-Experimental: true
  • Server: Docker/1.13.0-rc3 (linux)

Here is my API version:

{
    "Version": "1.13.0-rc3",
    "ApiVersion": "1.25",
    "MinAPIVersion": "1.12",
    "GitCommit": "4d92237",
    "GoVersion": "go1.7.3",
    "Os": "linux",
    "Arch": "amd64",
    "KernelVersion": "4.8.12-moby",
    "Experimental": true,
    "BuildTime": "2016-12-06T01:15:44.725283878+00:00"
}

Am I missing anything here?

Dan Lowe
  • 51,713
  • 20
  • 123
  • 112
sam
  • 568
  • 1
  • 8
  • 16
  • Did you set it by daemon.json? I'm running into the same issue on Ubuntu 16.04. For now I'm setting the deprecated option `--api-enable-cors=true` in the systemd config. – imwill Jan 26 '17 at 21:09
  • There was a few bugs with this in prior version. Should be fixed now via the answer below from Meiki – browserless Apr 08 '19 at 19:13

2 Answers2

5

Based on https://docs.browserless.io/docs/docker.html#enable-cors:

Enable CORS

You can enable cross-origin-resource-sharing with browserless by setting the ENABLE_CORS=true variable. This defaults to false:

$ docker run -e "ENABLE_CORS=true" -p 3000:3000 --restart always -d --name browserless browserless/chrome
Mehdi Nourollah
  • 166
  • 1
  • 11
0

It is also possible that problem is in another level, not the docker itself, for me I had a python flask application wrapped in a docker container. I found the solution here to the CORS.

....
from flask_cors import CORS
....


app = Flask(__name__)
CORS(app)
Naser Nikzad
  • 713
  • 12
  • 27