aio-libs / aio-libs/aiohttp-cors

403 Error when aiohttp resources are not fully merged

Abierto
#226 1 comentario 4 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
220
Forks
61
Merge medio
2 min
PR fusionados (30 d)
3

Descripción

Aiohttp merges resources, when they are added in the correct order:
![screenshot from 2019-02-22 15-40-04](https://user-images.githubusercontent.com/9722121/53249503-854fe980-36b8-11e9-9798-7862a9a283b3.png)

When using aiohttp-cors, resources have to be fully merged, or you end up having 2 resources for the same path, one for the GET method one for the POST, but the latter will not be considered when aiohttp-cors answers the OPTIONS request. It seems that aiohttp-cors supports only a single resource per path.

It would be nice if a hint about this could be added to the docs, if the support of multiple resources for the same path is too complex.

Requirements:
```
aiohttp==3.0.6
aiohttp_cors==0.7.0
```

Replicate:
```
def handler():
pass

app.router.add_route('POST', '/a', handler)
app.router.add_route('GET', '/b', handler)
app.router.add_route('PUT', '/a', handler)

# Configure default CORS settings.
cors = aiohttp_cors.setup(app, defaults={
"*": aiohttp_cors.ResourceOptions(
allow_credentials=True,
expose_headers="*",
allow_headers="*")
})

# Configure CORS on all routes.
for route in list(app.router.routes()):
cors.add(route)

```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.