cog icon indicating copy to clipboard operation
cog copied to clipboard

allow docker to bypass CORS w/env var DISABLE_CORS

Open anotherjesse opened this issue 3 years ago • 8 comments

It isn't documented in the README as it won't work on existing catalog of images. It is only for new images.

Signed-off-by: Jesse Andrews [email protected]

anotherjesse avatar Oct 01 '22 03:10 anotherjesse

I haven't looked at an automated test yet

anotherjesse avatar Oct 01 '22 03:10 anotherjesse

Thinking about this further it seems like having a command like:

cog serve r8.im/zeke/haiku-standard@sha256:78458ba6976fb7d159f9f3a336754d9e8467110c0fb7e8a2c86d93ccdb524f03

in cog serve you can address issues not directly related to the model:

  • handle CORS #713
  • static files #687
  • file handling #496 - and additionally where we can upload to GCS/S3/R2 or store in a local filesystem
  • make api consistent between requests against a local docker deploy and replicate deployment

Why not do this in python cog.server.http

  1. baking non-model specific code into models couple / complicate improvements to serving experience / existing cog'd model will always have older versions of "serve" (docker images)
  2. move file access/uploading outside of docker images to focus solely on running the model, not integrations beyond model

I haven't looked at the go code beyond determining how the python code is injected during model build time. Perhaps this is a poor idea that I'll see once I try to look at prototyping this.

anotherjesse avatar Oct 01 '22 14:10 anotherjesse

see POC in #738

anotherjesse avatar Oct 01 '22 16:10 anotherjesse

The name DISABLE_CORS is a bit ambiguous, as it could be taken to mean "do not allow cross-origin requests" or "allow any cross-origin request". Maybe something more explicit like BYPASS_CORS or CORS_ALLOW_ALL?

zeke avatar Oct 03 '22 21:10 zeke

hey I am blocked on this cors its a small thing but due to this its becoming pain for me to use the cog further. can we just get this rolling in ?

zeref94 avatar Nov 17 '22 14:11 zeref94

Blocked by this as well. Generally running Cog-powered models on production seem to be very restricted due to the fact that the http server is not modifiable. Allowing to modify the underlying FastAPI server would be greatly helpful.

sepehr avatar Feb 26 '24 13:02 sepehr

I am patching and using it myself. I hope this PR will be incorporated into production soon.

soshiharami avatar Sep 06 '24 05:09 soshiharami

Is this getting in any time soon? Or is there an alternative way to change CORS settings on the server?

dotKokott avatar Sep 18 '24 13:09 dotKokott