I'm already hosting another webserver on my device, so I need to proxy requests through that, and for that I'm using this script
import aiohttp
from aiohttp import web
async def proxy_request(request: web.Request):
original_path = request.path
original_query = request.query_string
target_domain = 'http://127.0.0.1:4007'
target_url = f'{target_domain}{original_path}'
if original_query:
target_url += f'?{original_query}'
async with aiohttp.ClientSession() as session:
async with session.request(
method=request.method,
url=target_url,
headers=request.headers,
data=await request.read()
) as resp:
headers = {k: v for k, v in resp.headers.items() if k.lower() != 'content-length'}
body = await resp.read()
return web.Response(status=resp.status, headers=headers, body=body)
the homepage loads perfectly fine, but when I try to do anything else, such as add a bot, it returns a 403
I'm already hosting another webserver on my device, so I need to proxy requests through that, and for that I'm using this script
the homepage loads perfectly fine, but when I try to do anything else, such as add a bot, it returns a 403