1212
1313import aiobotocore .session
1414import aiohttp .web
15- import aiohttp_cors
1615import aiohttp_remotes
1716import botocore .exceptions
1817import pkg_resources
3837 Response ,
3938 StreamResponse ,
4039)
41- from aiohttp_cors import CorsConfig
4240from aiohttp_security import check_authorized , check_permission
4341from multidict import CIMultiDict , CIMultiDictProxy
4442from neuro_auth_client import AuthClient , Permission , User
6159from .basic import BasicUpstream
6260from .config import (
6361 Config ,
64- CORSConfig ,
6562 EnvironConfigFactory ,
6663 UpstreamRegistryConfig ,
6764 UpstreamType ,
@@ -240,7 +237,7 @@ def _registry_client(self) -> aiohttp.ClientSession:
240237 def _upstream (self ) -> Upstream :
241238 return self ._app ["upstream" ]
242239
243- def register (self , app : aiohttp .web .Application , cors : CorsConfig ) -> None :
240+ def register (self , app : aiohttp .web .Application ) -> None :
244241 app .add_routes (
245242 (
246243 aiohttp .web .get ("/" , self .handle_version_check ),
@@ -263,9 +260,6 @@ def register(self, app: aiohttp.web.Application, cors: CorsConfig) -> None:
263260 METH_PUT ,
264261 )
265262 )
266- for route in app .router .routes ():
267- logger .debug (f"Setting up CORS for { route } " )
268- cors .add (route )
269263
270264 def _create_url_factory (self , request : Request ) -> URLFactory :
271265 return URLFactory .from_config (
@@ -932,29 +926,11 @@ def make_tracing_trace_configs(config: Config) -> list[aiohttp.TraceConfig]:
932926 return trace_configs
933927
934928
935- def _setup_cors (app : aiohttp .web .Application , config : CORSConfig ) -> CorsConfig :
936- if not config .allowed_origins :
937- return aiohttp_cors .setup (app )
938-
939- logger .info (f"Setting up CORS with allowed origins: { config .allowed_origins } " )
940- default_options = aiohttp_cors .ResourceOptions (
941- allow_credentials = True ,
942- expose_headers = "*" ,
943- allow_headers = "*" ,
944- )
945- cors = aiohttp_cors .setup (
946- app , defaults = {origin : default_options for origin in config .allowed_origins }
947- )
948- return cors
949-
950-
951929async def create_app (config : Config ) -> aiohttp .web .Application :
952930 app = aiohttp .web .Application ()
953931
954932 await aiohttp_remotes .setup (app , aiohttp_remotes .XForwardedRelaxed ())
955933
956- cors = _setup_cors (app , config .cors )
957-
958934 async def _init_app (app : aiohttp .web .Application ) -> AsyncIterator [None ]:
959935 async with AsyncExitStack () as exit_stack :
960936
@@ -1016,7 +992,7 @@ async def on_request_redirect(
1016992
1017993 v2_app = aiohttp .web .Application ()
1018994 v2_handler = V2Handler (app = v2_app , config = config )
1019- v2_handler .register (v2_app , cors )
995+ v2_handler .register (v2_app )
1020996
1021997 app ["v2_app" ] = v2_app
1022998 app .add_subapp ("/v2" , v2_app )
0 commit comments