Comments (5)
Hi @Dogfalo,
Yes, there is a known issue with aiohttp-cors
, that it doesnโt allow to provide CORS headers for OPTIONS requests cause of the error you mentioned, as it tries to setup a handler for OPTIONS request, but is is already taken
I suggest you to give a try of aiohttp-middlewares and its cors_middleware
as it allows to provide CORS headers even for OPTIONS requests
Hope it will work out for you
โโ
To make it more obvious, Iโll update the documentation with tutorial on how to provide CORS headers for aiohttp-tus
library
from aiohttp-tus.
Thanks for the reply! I am just trying to understand, what makes the aiohttp-middleware different? Does it just add headers into the response of the handler without trying to create a new handler?
from aiohttp-tus.
The high-level details described in aiohttp-middlewares docs, but if you need more technical details, here they go.
aiohttp-cors
registersOPTIONS
handler to deal with CORS preflight requests, this resulted in two issues:- Inability to use
aiohttp-cors
with otherOPTIONS
handlers - Inability to use
aiohttp-cors
with wildcard*
handlers, aio-libs/aiohttp-cors#241
- Inability to use
- While
cors_middleware
is a regular middleware, which does not register any handlers for dealing with preflight requests. It checks, whether current request is a CORS preflight and if so, does not call handler, but provide an empty response to satisfy CORS needs.
This difference allows cors_middleware
to fix both of aiohttp-cors
issues as well as simplify dealing with CORS headers for aiohttp.web
applications at all, as their setup looks like,
from aiohttp import web
from aiohttp_middlewares import cors_middleware
# Allow CORS requests from URL http://localhost:3000
app = web.Application(
middlewares=[
cors_middleware(origins=["http://localhost:3000"])
]
)
More examples available in cors_middleware
docs.
Hope this makes sense for you.
from aiohttp-tus.
Makes sense, thanks for the explanation!
from aiohttp-tus.
Docs updated: https://aiohttp-tus.readthedocs.io/en/latest/usage.html#cors-headers
from aiohttp-tus.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aiohttp-tus.