Neoteroi / BlackSheep

Fast ASGI web framework for Python
https://www.neoteroi.dev/blacksheep/
MIT License
1.8k stars 75 forks source link

use_cors not adding headers in the response #355

Closed oprog closed 1 year ago

oprog commented 1 year ago

Describe the bug I have a working API based on blacksheep - v1.2.14. Using gunicorn and uvicorn too. I'm simply using the code below (from here) in my app but I can't see any expected header in the response

app.use_cors(
    allow_methods="*",
    allow_origins="*",
    allow_headers="* ",
    max_age=300
)

I did a test with this code (localhost)

from blacksheep import Application, text, Request

app = Application(show_error_details=True)
app.use_cors(allow_methods="*",
    allow_origins="*",
    allow_headers="*")

post = app.router.post

@post("/test")
async def test(request: Request):
    return text("OK")

I tested it with Postman, not in browser and still no Access-Control-Allow-Origin headers etc. in the response.

Am I doing something wrong, what am I missing?