miro: make proxy image thought Caddy

This commit is contained in:
ZhymabekRoman 2024-07-22 11:40:31 +05:00
parent 3876fef698
commit 1151e9388f
5 changed files with 21 additions and 5 deletions

View file

@ -162,6 +162,11 @@
respond "Access denied" 403
}
route @miro/* {
uri replace @miro/ /
reverse_proxy https://miro.medium.com
}
route /* {
reverse_proxy web:7080
}

View file

@ -5,6 +5,11 @@
{{ template }}
route @miro/* {
uri replace @miro/ /
reverse_proxy https://miro.medium.com
}
route /* {
reverse_proxy web:7080
}

View file

@ -6,6 +6,11 @@ freedium.cfd {
{{ template }}
route @miro/* {
uri replace @miro/ /
reverse_proxy https://miro.medium.com
}
route /* {
reverse_proxy web:7080
}

View file

@ -39,10 +39,10 @@ async def route_processing(path: str, request: Request):
if key_data != config.ADMIN_SECRET_KEY:
return JSONResponse({"message": f"Wrong secret key: {key_data}"}, status_code=403)
if path.startswith("@miro/"):
miro_data = path.removeprefix("@miro/")
return await miro_proxy(miro_data)
elif path.startswith("render_iframe/"):
# if path.startswith("@miro/"):
# miro_data = path.removeprefix("@miro/")
# return await miro_proxy(miro_data)
if path.startswith("render_iframe/"):
iframe_id = path.removeprefix("render_iframe/")
return await iframe_proxy(iframe_id)

View file

@ -8,8 +8,9 @@ from bs4 import BeautifulSoup, Comment
IFRAME_HEADERS = {"Access-Control-Allow-Origin": "*", "X-Frame-Options": "SAMEORIGIN"}
@trace
async def iframe_proxy(iframe_id):
async def iframe_proxy(iframe_id: str):
# How Medium embeds works: https://stackoverflow.com/questions/56594766/medium-embed-ly-notifyresize-does-not-work-on-safari
async with aiohttp.ClientSession() as client:
request = await client.get(