hug icon indicating copy to clipboard operation
hug copied to clipboard

Fixing the cors middleware to address the KeyError via issue #767

Open ulmentflam opened this issue 4 years ago • 1 comments

ulmentflam avatar Feb 08 '21 18:02 ulmentflam

If anyone needs this fix before it is merged in, you can add the CORSMiddleware class to a file in your project and import the new CORSMiddleware class and add it in the same way you add other middleware. For example:

# In your imports
from {your_project}.{file_with_middleware_class_from_this_pr} import CORSMiddleware

# After you create the Hug API
api.http.add_middleware(CORSMiddleware(api, allow_origins=['*'], max_age=10))

ulmentflam avatar May 26 '21 14:05 ulmentflam