File tree 4 files changed +34
-1
lines changed
4 files changed +34
-1
lines changed Original file line number Diff line number Diff line change 5
5
from fastapi import FastAPI
6
6
from tqdm .contrib .logging import logging_redirect_tqdm
7
7
8
- from . import resources
8
+ from . import middleware , resources
9
9
10
10
LOG = logging .getLogger (__name__ )
11
11
@@ -28,4 +28,6 @@ async def app_lifespan_handler(app: FastAPI):
28
28
def init_app ():
29
29
app = FastAPI (lifespan = app_lifespan_handler )
30
30
resources .init_app (app )
31
+ middleware .init_middleware (app )
32
+
31
33
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