Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
asgi-cors-strawberry
Advanced tools
ASGI middleware to apply CORS header especially for Strawberry GraphQL
pip install asgi-cors-strawberry
According to mdn MDN - CORS, cross-origin requests are preflighted using OPTIONS method. The response from preflight has Access-Control-Allow-Origin, Access-Control-Allow-Headers, etc.
Since Strawberry GraphQL Consumer is designed to handle only GET and POST methods, if you use general ASGI CORS middleware, you will get a 405 code as a response to preflight.
# in django asgi.py
from asgi_cors_strawberry import CorsMiddleware
...
application = ProtocolTypeRouter(
{
"http": URLRouter(
[
re_path(r"^graphql", GraphQLHTTPConsumer.as_asgi(schema=schema)),
re_path(r"^", get_asgi_application()),
]
),
"websocket": URLRouter([
re_path(r"^graphql", GraphQLWSConsumer.as_asgi(schema=schema))
])
}
)
application = CorsMiddleware(application)
The example above is an ASGI application using Strawberry-GraphQL[Channels]
True if all hosts are allowed
if allow_all is False, hosts is a list of allowed hosts
you can use wildcards in hosts, like ["*.example.com"]
you can add headers to Access-Control-Allow-Headers
default header is "content-type" because gql will be passed to the request
FAQs
ASGI middleware for CORS, especially for using strawberry-graphql
We found that asgi-cors-strawberry demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.