add terms page, improve landing content for branding review, and handle HTTP HEAD requests
This commit is contained in:
+21
@@ -42,6 +42,27 @@ async def redirect_http_to_https(request: Request, call_next):
|
||||
return await call_next(request)
|
||||
|
||||
|
||||
@app.middleware("http")
|
||||
async def support_head_requests(request: Request, call_next):
|
||||
# 이 Starlette 버전은 GET 라우트에 HEAD를 자동으로 열어주지 않아 크롤러의 HEAD 요청이
|
||||
# 전부 405로 막힌다(구글 OAuth 브랜딩 인증 크롤러가 홈페이지를 HEAD로 먼저 확인하면서
|
||||
# "콘텐츠 없음"으로 오판하는 원인이 됐음). GET과 동일하게 처리한 뒤 본문만 비워서 응답한다.
|
||||
if request.method != "HEAD":
|
||||
return await call_next(request)
|
||||
|
||||
request.scope["method"] = "GET"
|
||||
response = await call_next(request)
|
||||
|
||||
async def _empty_body():
|
||||
return
|
||||
yield b"" # pragma: no cover - 제너레이터로 만들기 위한 도달 불가 코드
|
||||
|
||||
response.body_iterator = _empty_body()
|
||||
# uvicorn은 실제 전송 바이트와 Content-Length가 다르면 예외를 던지므로 0으로 맞춘다.
|
||||
response.headers["content-length"] = "0"
|
||||
return response
|
||||
|
||||
|
||||
app.mount("/static", StaticFiles(directory="app/static"), name="static")
|
||||
|
||||
app.include_router(auth.router)
|
||||
|
||||
Reference in New Issue
Block a user