fix:修复接口调用问题
This commit is contained in:
@@ -49,6 +49,18 @@ CONTENT_SECURITY_POLICY = "; ".join(
|
||||
)
|
||||
|
||||
|
||||
def build_response_headers() -> dict[str, str]:
|
||||
headers = {
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
"Referrer-Policy": "no-referrer",
|
||||
"Cache-Control": "public, max-age=300",
|
||||
}
|
||||
if not settings.allow_unsafe_html:
|
||||
headers["Content-Security-Policy"] = CONTENT_SECURITY_POLICY
|
||||
|
||||
return headers
|
||||
|
||||
|
||||
def require_api_key(x_api_key: str | None = Header(default=None, alias="X-API-Key")) -> None:
|
||||
if not settings.api_key:
|
||||
return
|
||||
@@ -316,10 +328,5 @@ def get_html_content(unique_id: str, db: Session = Depends(get_db)) -> FileRespo
|
||||
return FileResponse(
|
||||
path=file_path,
|
||||
media_type="text/html",
|
||||
headers={
|
||||
"Content-Security-Policy": CONTENT_SECURITY_POLICY,
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
"Referrer-Policy": "no-referrer",
|
||||
"Cache-Control": "public, max-age=300",
|
||||
},
|
||||
headers=build_response_headers(),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user