File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55from fastapi import FastAPI
66from tqdm .contrib .logging import logging_redirect_tqdm
77
8- from . import resources
8+ from . import middleware , resources
99
1010LOG = logging .getLogger (__name__ )
1111
@@ -28,4 +28,6 @@ async def app_lifespan_handler(app: FastAPI):
2828def init_app ():
2929 app = FastAPI (lifespan = app_lifespan_handler )
3030 resources .init_app (app )
31+ middleware .init_middleware (app )
32+
3133 return app
Original file line number Diff line number Diff line change 1+ from .middleware import init_middleware
2+
3+ __all__ = ["init_middleware" ]
Original file line number Diff line number Diff line change 1+
2+ from fastapi import FastAPI
3+ from fastapi .middleware .cors import CORSMiddleware
4+
5+
6+ def init_middleware (app : FastAPI ):
7+ # TODO: Allow this to be configurable
8+ app .add_middleware (
9+ CORSMiddleware ,
10+ allow_credentials = True ,
11+ allow_origins = ["*" ],
12+ allow_methods = ["*" ],
13+ allow_headers = ["*" ],
14+ )
Original file line number Diff line number Diff line change 1+ import logging
2+
3+ from fastapi import FastAPI
4+
5+ LOG = logging .getLogger (__name__ )
6+
7+
8+ def init_middleware (app : FastAPI ):
9+ from . import cors
10+
11+ # NOTE: Add more middleware here
12+
13+ LOG .info ("Adding `CORS` middleware" )
14+ cors .init_middleware (app )
You can’t perform that action at this time.
0 commit comments