| |
@@ -2,6 +2,7 @@
|
| |
import logging.config
|
| |
|
| |
from aiohttp import web
|
| |
+ from aiohttp.web import middleware
|
| |
|
| |
from mdapi import CONFIG
|
| |
from mdapi.views import (
|
| |
@@ -21,6 +22,12 @@
|
| |
get_pkg_changelog
|
| |
)
|
| |
|
| |
+ @middleware
|
| |
+ async def add_cors_headers(request, handler):
|
| |
+ resp = await handler(request)
|
| |
+ resp.headers['Access-Control-Allow-Origin'] = '*'
|
| |
+ resp.headers['Access-Control-Allow-Methods'] = 'GET'
|
| |
+ return resp
|
| |
|
| |
async def init_app():
|
| |
""" Creates the aiohttp application.
|
| |
@@ -30,7 +37,7 @@
|
| |
logging.basicConfig()
|
| |
logging.config.dictConfig(CONFIG.get("LOGGING") or {"version": 1})
|
| |
|
| |
- app = web.Application()
|
| |
+ app = web.Application(middlewares=[add_cors_headers])
|
| |
|
| |
app.add_routes([
|
| |
web.get('/', index),
|
| |
As we query get_src_pkg from src.fp.o with a request for json,
we need to respond with json plus some additional headers to
tell modern browsers that this cross-origin HTTP request
should be allowed.
Signed-off-by: Karsten Hopp karsten@redhat.com