Skip to content

Commit 7491de5

Browse files
committed
chore: add cors endpoint filter
1 parent 52f52c0 commit 7491de5

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

koala/env.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@
2020
if os.name == 'nt':
2121
CONFIG_PATH = '.'+CONFIG_PATH
2222

23-
LOGGING_FILE = eval(os.environ.get("LOGGING_FILE", "True"))
23+
LOGGING_FILE = eval(os.environ.get("LOGGING_FILE", "True"))
24+
25+
FRONTEND_URL = os.environ.get("FRONTEND_URL", "http://localhost:3000")

koalabot.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
import discord
2424
# Libs
2525
from aiohttp import web
26+
import aiohttp_cors
2627
from discord.ext import commands
2728

29+
from koala import env
2830
# Own modules
2931
from koala.db import extension_enabled
3032
from koala.env import BOT_TOKEN, BOT_OWNER, API_PORT
@@ -184,8 +186,8 @@ def check_guild_has_ext(ctx, extension_id):
184186

185187
async def run_bot():
186188
app = web.Application()
189+
aiohttp_cors.setup(app, defaults={env.FRONTEND_URL: aiohttp_cors.ResourceOptions()})
187190
bot = KoalaBot(command_prefix=[COMMAND_PREFIX, OPT_COMMAND_PREFIX], intents=intent)
188-
189191
setattr(bot, "koala_web_app", app)
190192
await load_all_cogs(bot)
191193

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
aiohttp==3.8.4
2+
aiohttp_cors==0.7.0
23
async-timeout==4.0.2
34
atomicwrites==1.4.1
45
attrs==22.2.0

0 commit comments

Comments
 (0)