cog icon indicating copy to clipboard operation
cog copied to clipboard

CORS fix for use on locahost

Open GrantSparks opened this issue 1 year ago • 1 comments

I had to add the following code to allow me to execute XHR requests from a local html/javascript file.

cog/python/cog/server/http.py

...

from fastapi.middleware.cors import CORSMiddleware

...

app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

GrantSparks avatar Sep 02 '22 10:09 GrantSparks

Thanks for sharing, @GrantSparks 👍🏼

zeke avatar Sep 02 '22 18:09 zeke

I did an initial pass at integrating this: https://github.com/replicate/cog/pull/737

anotherjesse avatar Oct 01 '22 03:10 anotherjesse