|
31 | 31 | async def referer_and_path_middleware(request: Request, call_next): |
32 | 32 | # Check the Referer header |
33 | 33 | referer = request.headers.get("referer") |
34 | | - allowed_referer = "https://ricardogarcia.uk" |
| 34 | + allowed_referers = ["https://ricardogarcia.uk", "https://rigsnv-ejfqade8hydkh3c8.uksouth-01.azurewebsites.net/"] |
35 | 35 |
|
36 | 36 | # Check the request path |
37 | 37 | allowed_paths = ["/weather", "/pcs_contracts"] |
38 | 38 |
|
39 | | - if referer and referer.startswith(allowed_referer) and request.url.path in allowed_paths: |
| 39 | + if referer and any(referer.startswith(allowed) for allowed in allowed_referers) and request.url.path in allowed_paths: |
40 | 40 | response = await call_next(request) |
41 | 41 | return response |
42 | 42 |
|
@@ -78,4 +78,12 @@ def update_contracts(date_from=None, notice_type=3, output_type=0): |
78 | 78 | client = PCSClient() |
79 | 79 | return client.get_pcs_contracts(date_from=date_from, notice_type=notice_type, output_type=output_type) |
80 | 80 |
|
| 81 | +@app.options("/{path:path}") |
| 82 | +async def preflight_handler(): |
| 83 | + return JSONResponse(status_code=200, headers={ |
| 84 | + "Access-Control-Allow-Origin": "https://ricardogarcia.uk", |
| 85 | + "Access-Control-Allow-Methods": "GET, POST, PUT, OPTIONS", |
| 86 | + "Access-Control-Allow-Headers": "Content-Type, Authorization", |
| 87 | + }) |
| 88 | + |
81 | 89 | #test, this should trigger a build |
0 commit comments