|
11 | 11 | origins = [ |
12 | 12 | "https://ricardogarcia.uk", |
13 | 13 | "https://www.ricardogarcia.uk", |
14 | | - "https://ricardogarcia.uk/weather", |
15 | | - "https://ricardogarcia.uk/pcs_contracts", |
16 | | - "https://217.160.0.207", |
17 | 14 | "https://rigsnv-ejfqade8hydkh3c8.uksouth-01.azurewebsites.net", |
18 | 15 | "http://localhost:5173", |
19 | 16 | "http://127.0.0.1/5173", |
|
27 | 24 | allow_headers=["*"], |
28 | 25 | ) |
29 | 26 |
|
30 | | -@app.middleware("http") |
31 | | -async def referer_and_path_middleware(request: Request, call_next): |
32 | | - # Check the Referer header |
33 | | - referer = request.headers.get("referer") |
34 | | - allowed_referers = origins |
35 | | - |
36 | | - # Check the request path |
37 | | - allowed_paths = ["/weather", "/pcs_contracts"] |
38 | | - |
39 | | - if referer and any(referer.startswith(allowed) for allowed in allowed_referers) and request.url.path in allowed_paths: |
40 | | - response = await call_next(request) |
41 | | - return response |
42 | | - |
43 | | - return JSONResponse(status_code=403, content={"detail": "Forbidden: Invalid referer or path"}) |
44 | | - |
45 | 27 | @app.get("/") |
46 | 28 | async def root(): |
47 | 29 | return{"message": "Hello World of Fast APIs on Azure!"} |
@@ -77,5 +59,3 @@ def get_contracts(): |
77 | 59 | def update_contracts(date_from=None, notice_type=3, output_type=0): |
78 | 60 | client = PCSClient() |
79 | 61 | return client.get_pcs_contracts(date_from=date_from, notice_type=notice_type, output_type=output_type) |
80 | | - |
81 | | -#test, this should trigger a build |
0 commit comments