Skip to content

Commit

Permalink
feat: Allow more control over CORS
Browse files Browse the repository at this point in the history
  • Loading branch information
null2264 committed Jul 21, 2023
1 parent d4fcfff commit b84f4b8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ DISCORD_CLIENT_SECRET=""
DISCORD_REDIRECT_URI="http://127.0.0.1:8000/callback"
DISCORD_GUILD_REDIRECT_URI="http://127.0.0.1:8000/guild-callback"
DASHBOARD_FRONTEND_URI="http://127.0.0.1"
# optional, if empty it'll use DASHBOARD_FRONTEND_URI by default, separated by comma
DASHBOARD_FRONTEND_CORS="http://zibot.local,http://dev.zibot.local"
DASHBOARD_HOSTNAME="127.0.0.1" # mainly for cookie domain
DASHBOARD_ZMQ_SUB="127.0.0.1:5554"
# in docker-compose you can do something like this depending on your setup
Expand Down
2 changes: 1 addition & 1 deletion nexus/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, context: Optional[zmq.asyncio.Context] = None, *args, **kwarg
self.add_event_handler("shutdown", self.onShutdown)
self.add_middleware(
CORSMiddleware,
allow_origins=[self.frontendUri],
allow_origins=os.getenv("DASHBOARD_FRONTEND_CORS", self.frontendUri).split(","),
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
Expand Down

0 comments on commit b84f4b8

Please sign in to comment.