TheHellTower / Discord-Bot-List

Live Version: https://dbl.ovh
https://dbl.ovh
GNU General Public License v3.0
17 stars 11 forks source link

Site doesn't work with proxy/cloudflare #109

Open eepyfemboi opened 1 week ago

eepyfemboi commented 1 week ago

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 image

eepyfemboi commented 1 week ago

forgot to mention, it works perfectly fine when i go to http://127.0.0.1:4007 in my browser