style agenda
This commit is contained in:
parent
737781e9aa
commit
7dd38624a4
7 changed files with 471 additions and 161 deletions
|
@ -2,6 +2,7 @@
|
|||
Middleware components for the OpenEventDatabase.
|
||||
"""
|
||||
|
||||
import falcon
|
||||
from oedb.utils.logging import logger
|
||||
|
||||
class HeaderMiddleware:
|
||||
|
@ -9,6 +10,21 @@ class HeaderMiddleware:
|
|||
Middleware that adds standard headers to all responses.
|
||||
"""
|
||||
|
||||
def process_request(self, req, resp, resource, params):
|
||||
"""
|
||||
Handle preflight OPTIONS requests for CORS.
|
||||
|
||||
Args:
|
||||
req: The request object.
|
||||
resp: The response object.
|
||||
resource: The resource object.
|
||||
params: The request parameters.
|
||||
"""
|
||||
if req.method == 'OPTIONS':
|
||||
logger.debug("Handling CORS preflight request")
|
||||
resp.status = falcon.HTTP_200
|
||||
return True # Skip further processing
|
||||
|
||||
def process_response(self, req, resp, resource, params):
|
||||
"""
|
||||
Add standard headers to the response.
|
||||
|
@ -21,7 +37,15 @@ class HeaderMiddleware:
|
|||
"""
|
||||
logger.debug("Adding standard headers to response")
|
||||
resp.set_header('X-Powered-By', 'OpenEventDatabase')
|
||||
|
||||
# CORS headers - Configuration optimisée pour embed.js
|
||||
resp.set_header('Access-Control-Allow-Origin', '*')
|
||||
resp.set_header('Access-Control-Allow-Headers', 'X-Requested-With')
|
||||
resp.set_header('Access-Control-Allow-Headers', 'Content-Type')
|
||||
resp.set_header('Access-Control-Allow-Methods','GET, POST, PUT, DELETE, OPTIONS')
|
||||
resp.set_header('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, Authorization, Accept, Origin, User-Agent, Referer')
|
||||
resp.set_header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS, HEAD')
|
||||
resp.set_header('Access-Control-Allow-Credentials', 'false')
|
||||
resp.set_header('Access-Control-Max-Age', '86400') # 24 hours
|
||||
resp.set_header('Access-Control-Expose-Headers', 'Content-Length, Content-Type, Date, Server, X-Powered-By')
|
||||
|
||||
# Headers supplémentaires pour embed.js
|
||||
resp.set_header('Vary', 'Origin')
|
||||
resp.set_header('Cache-Control', 'public, max-age=300') # Cache de 5 minutes pour les requêtes embed
|
Loading…
Add table
Add a link
Reference in a new issue