Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify the API's Server to Allow CORS #311

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/ask_astro/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from logging import getLogger

from sanic import Request, Sanic
from sanic_cors import CORS

from ask_astro.rest.controllers import register_routes
from ask_astro.slack.app import app_handler, slack_app
Expand All @@ -18,6 +19,8 @@

api = Sanic(name="ask_astro")

CORS(api, resources={r"/api/*": {"origins": "*"}})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general it is not a good practice to allow * wildcard origin. Specify a domain name or something here.

But why are we adding this? The current service works just fine without it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not adding it @davidgxue it was just for the hackathon as we were using dev API of ask-astro

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay sounds good. As long as you don't merge this in then that's cool!



# route slack requests to the slack app
@api.get("/slack/oauth_redirect", name="oauth_redirect")
Expand Down
19 changes: 17 additions & 2 deletions api/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ uvicorn = "^0.23.2"
tenacity = "^8.2.3"
cohere = "==4.39"
sanic_limiter = { git = "https://github.com/Omegastick/sanic-limiter.git"}
sanic-cors = "^2.2.0"

[tool.poetry.group.dev.dependencies]
pytest = "^7.4.2"
Expand Down
Loading
Loading