Skip to content

Commit 0411a67

Browse files
Merge pull request #47 from Clariteia/issue-46-cors-support
#46 - Add CORS support
2 parents 59ca2f3 + b81b0ac commit 0411a67

File tree

5 files changed

+191
-47
lines changed

5 files changed

+191
-47
lines changed

minos/api_gateway/rest/service.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
from aiohttp import (
66
web,
77
)
8+
from aiohttp_middlewares import (
9+
cors_middleware,
10+
)
811
from aiomisc.service.aiohttp import (
912
AIOHTTPService,
1013
)
@@ -25,7 +28,12 @@ def __init__(self, address: str, port: int, config: MinosConfig):
2528
super().__init__(address, port)
2629

2730
async def create_application(self) -> web.Application:
28-
app = web.Application()
31+
middlewares = list()
32+
if self.config.cors.enabled:
33+
middlewares = [cors_middleware(allow_all=True)]
34+
35+
app = web.Application(middlewares=middlewares)
36+
2937
app["config"] = self.config
3038

3139
app.router.add_route("*", "/{endpoint:.*}", handler.orchestrate)

0 commit comments

Comments
 (0)