Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -113,13 +113,13 @@ app.add_middleware(
|
|
| 113 |
)
|
| 114 |
|
| 115 |
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
|
| 124 |
|
| 125 |
@app.get("/image")
|
|
|
|
| 113 |
)
|
| 114 |
|
| 115 |
|
| 116 |
+
@app.middleware("http")
|
| 117 |
+
async def validate_origin(request: Request, call_next):
|
| 118 |
+
if DEV:
|
| 119 |
+
return await call_next(request)
|
| 120 |
+
if request.headers.get("referer") not in origins:
|
| 121 |
+
raise HTTPException(status_code=403, detail="Forbidden")
|
| 122 |
+
return await call_next(request)
|
| 123 |
|
| 124 |
|
| 125 |
@app.get("/image")
|