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

Middleware short circuit does not use app.api.cors setting #2059

Open
nineclicks opened this issue Jul 19, 2023 · 0 comments
Open

Middleware short circuit does not use app.api.cors setting #2059

nineclicks opened this issue Jul 19, 2023 · 0 comments

Comments

@nineclicks
Copy link

chalice 1.29.0
Python 3.11.4
Windows 10.0.19045 Build 19045

from chalice import Chalice, Response

app = Chalice(app_name='chalice-test')
app.api.cors = True

@app.middleware('http')
def middle(event, get_response):
    return Response({'test': 123})

@app.route('/test')
def index():
    return {'hello': 'world'}

Without the middleware, /test returns headers

  • Access-Control-Allow-Origin: *
  • Access-Control-Allow-Headers: Authorization,Content-Type,X-Amz-Date,X-Amz-Security-Token,X-Api-Key

With the middleware function, these headers are not set. Expected behavior is that CORS headers would be set app-wide when using app.api.cors. I cannot find anything in the docs indicating that CORS should not be set by middleware.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant