mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-09-19 08:20:42 +03:00
Merge pull request #2664 from yueguobin/fix/symbol-cors-headers
Fix/symbol cors headers
This commit is contained in:
commit
da5a1e9172
@ -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}")
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user