Skip to content

Commit 3e172da

Browse files
authored
Merge pull request #12 from team-MoPlus/develop
Fix: cors in local
2 parents beda893 + 7cf147f commit 3e172da

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

__pycache__/main.cpython-312.pyc

-174 Bytes
Binary file not shown.
67 Bytes
Binary file not shown.

__pycache__/utils.cpython-312.pyc

84 Bytes
Binary file not shown.

main.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import asyncio
1818
import os
1919
from reportlab.pdfgen import canvas
20+
from urllib.parse import quote
2021

2122

2223
load_dotenv()
@@ -25,7 +26,7 @@
2526

2627
models.Base.metadata.create_all(bind=engine)
2728

28-
app = FastAPI(root_path="/api/fastapi")
29+
app = FastAPI()
2930

3031
app.add_middleware(
3132
CORSMiddleware,
@@ -109,13 +110,10 @@ def get_image_url(problem_id: int, db:Session=Depends(get_db)):
109110
@app.post("/download-review")
110111
async def download_review_note(data: PDFBody):
111112
buffer = io.BytesIO()
112-
await create_review_note(data.test_result, data.file_name, buffer)
113+
return create_review_note(data.test_result, data.file_name, buffer)
113114

114-
headers = {
115-
"Content-Disposition": f"attachment; filename={data.file_name}",
116-
"Access-Control-Allow-Origin": "https://www.mopl.kr", # 클라이언트 도메인 추가
117-
"Access-Control-Allow-Methods": "POST, OPTIONS", # 허용 메서드 추가
118-
"Access-Control-Allow-Headers": "*", # 허용 헤더 추가
119-
}
115+
# headers = {
116+
# "Content-Disposition": f"attachment; filename*=UTF-8''{data.file_name}",
117+
# }
120118

121-
return StreamingResponse(buffer, headers=headers, media_type="application/pdf")
119+
# return StreamingResponse(buffer, headers=headers, media_type="application/pdf")

0 commit comments

Comments
 (0)