imaginary icon indicating copy to clipboard operation
imaginary copied to clipboard

CORS errors

Open jlvdh opened this issue 4 years ago • 2 comments

I'm using the following setup:

  imaginary:
    image: h2non/imaginary:latest
    environment:
       PORT: 9000
       DEBUG: "*"
    command: -cors -enable-url-source -enable-auth-forwarding -allowed-origins <image-service>
    ports:
      - "9001:9000"

And when I'm fetching the image in my code:

await fetch(src, {
      method: 'GET',
      headers: {
        Authorization: Bearer <token>
      },
    })

But I'm still getting a cors error.

has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Setup works using postman. Any help would be greatly appreciated :)

jlvdh avatar Mar 13 '21 08:03 jlvdh

I'm having the same issue, it works with CURL but in the browser it fails.

I've got a Dockerfile setup like so:

FROM h2non/imaginary:latest

ENV DEBUG *

# @TODO: Add origins here via terraform or something
CMD ["-cors", "-allowed-origins", "http://localhost:3000"]

EXPOSE 9000

I get the CORS header ‘Access-Control-Allow-Origin’ missing error in my console, and according to firefox it only returns

HTTP/1.1 405 Method Not Allowed
Content-Type: application/json
Date: Mon, 22 Mar 2021 23:22:42 GMT
Content-Length: 123

with no body. This is in response to the OPTIONS preflight request.

Redmega avatar Mar 22 '21 23:03 Redmega

HI @Redmega, we finally got it running with these changes: https://github.com/jlvdh/sd-imaginary/commit/d377948209dc5be0d2330d7310642cf43bc78c48#

jlvdh avatar Mar 24 '21 14:03 jlvdh