Skip to main content

CORS support for API Star via event hooks.

Project description

This project enables CORS on API Star apps via event hooks.


  • apistar>=0.4.0
  • python>=3.6


Install via PyPI:

pip install apistar_cors_hooks

After installing, we need to add and instance of CORSRequestHooks to your event_hooks in your app:

from apistar import App, Route
from apistar_cors_hooks import CORSRequestHooks

def homepage() -> str:
    return '<html><body><h1>Homepage</h1></body></html>'

routes = [
    Route('/', method='GET', handler=homepage),

event_hooks = [CORSRequestHooks()]
app = App(routes=routes, event_hooks=event_hooks)

If you want to customize WSGICORS options, you just need to pass a dict via the options kwarg:

custom_options = {"origin": "your_host_server"}
event_hooks = [CORSRequestHooks(options=custom_options)]
app = App(routes=routes, event_hooks=event_hooks)


Since I’m a WSGI/CORS noob, I may have left a bug or two, or didn’t think of better ways to implement this.

Be free to open an issue, contribute with PRs and contact me at



  • adds README.rst as long description on PyPI


  • initial version

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for apistar-cors-hooks, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size apistar_cors_hooks-0.1.1-py3-none-any.whl (3.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size apistar_cors_hooks-0.1.1.tar.gz (2.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page