Merge pull request #2664 from yueguobin/fix/symbol-cors-headers

Fix/symbol cors headers
This commit is contained in:
Jeremy Grossmann 2026-04-07 22:27:47 +08:00 committed by GitHub
commit da5a1e9172
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -58,10 +58,9 @@ def get_symbols() -> List[dict]:
@router.get(
"/{symbol_id:path}/raw",
responses={404: {"model": schemas.ErrorMessage, "description": "Could not find symbol"}},
# FIXME: this is a temporary workaround due to a bug in the web-ui: https://github.com/GNS3/gns3-web-ui/issues/1466
# dependencies=[Depends(has_privilege("Symbol.Audit"))]
dependencies=[Depends(has_privilege("Symbol.Audit"))]
)
async def get_symbol(symbol_id: str) -> FileResponse:
async def get_symbol(symbol_id: str, request: Request) -> Response:
"""
Download a symbol file.
@ -71,7 +70,12 @@ async def get_symbol(symbol_id: str) -> FileResponse:
controller = Controller.instance()
try:
symbol = controller.symbols.get_path(symbol_id)
return FileResponse(symbol)
return FileResponse(
symbol,
headers={
"Access-Control-Allow-Origin": request.headers.get("origin", "*"),
}
)
except (KeyError, OSError) as e:
raise ControllerNotFoundError(f"Could not get symbol file: {e}")