Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site doesn't work with proxy/cloudflare #109

Closed
eepyfemboi opened this issue Sep 14, 2024 · 2 comments
Closed

Site doesn't work with proxy/cloudflare #109

eepyfemboi opened this issue Sep 14, 2024 · 2 comments
Labels
invalid This doesn't seem right

Comments

@eepyfemboi
Copy link

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
Copy link
Author

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

@TheHellTower TheHellTower added the invalid This doesn't seem right label Dec 2, 2024
@TheHellTower
Copy link
Owner

The template isn't respected.

https://github.com/TheHellTower/Discord-Bot-List/issues/new?assignees=&labels=&projects=&template=bug_report.md&title=

Also it is working(the demo run behind cloudflare)

Repository owner locked and limited conversation to collaborators Dec 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants