From 04c6bce0ca308bfc78ca9f1c57ea70e3c2724df2 Mon Sep 17 00:00:00 2001 From: Kingbro6 <99345187+MrHyplex9511@users.noreply.github.com> Date: Mon, 14 Sep 2026 14:01:46 +0530 Subject: [PATCH] Bounty #2127: Fix Beacon Atlas auto-registration + routing Add exact-match nginx locations for /beacon/join (POST) and /beacon/atlas (GET) in both server blocks (8070 dev and rustchain.org), proxying to the Atlas API on 127.0.0.1:8071. node/beacon_api.py already implements both routes (upsert, 400 on invalid pubkey_hex); the 404s were missing reverse- proxy routes, not missing app code. Regression tests added to tests/test_rustchain_org_nginx_config.py. --- site/nginx-rustchain-org.conf | 58 ++++++++++++++++++++++++ tests/test_rustchain_org_nginx_config.py | 22 +++++++++ 2 files changed, 80 insertions(+) diff --git a/site/nginx-rustchain-org.conf b/site/nginx-rustchain-org.conf index c3fdbac55..0be6eae9b 100644 --- a/site/nginx-rustchain-org.conf +++ b/site/nginx-rustchain-org.conf @@ -95,6 +95,35 @@ server { } } + # Beacon Atlas agent auto-registration (bounty #2127: POST /beacon/join + # must reach the Atlas API on 8071; app route lives in node/beacon_api.py) + location = /beacon/join { + proxy_pass http://127.0.0.1:8071/beacon/join; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_read_timeout 30s; + add_header Access-Control-Allow-Origin "*" always; + add_header Access-Control-Allow-Methods "POST, OPTIONS" always; + add_header Access-Control-Allow-Headers "Content-Type, Authorization" always; + if ($request_method = OPTIONS) { + return 204; + } + } + + # Beacon Atlas agent listing (bounty #2127: GET /beacon/atlas) + location = /beacon/atlas { + proxy_pass http://127.0.0.1:8071/beacon/atlas; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_read_timeout 30s; + add_header Access-Control-Allow-Origin "*" always; + add_header Access-Control-Allow-Methods "GET, OPTIONS" always; + add_header Access-Control-Allow-Headers "Content-Type, Authorization" always; + if ($request_method = OPTIONS) { + return 204; + } + } + # BEP-2: External Agent Relay endpoints # Beacon SEO: Agent profiles, directory, sitemap, llms.txt location /beacon/agent/ { @@ -436,6 +465,35 @@ server { } } + # Beacon Atlas agent auto-registration (bounty #2127: POST /beacon/join + # must reach the Atlas API on 8071; app route lives in node/beacon_api.py) + location = /beacon/join { + proxy_pass http://127.0.0.1:8071/beacon/join; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_read_timeout 30s; + add_header Access-Control-Allow-Origin "*" always; + add_header Access-Control-Allow-Methods "POST, OPTIONS" always; + add_header Access-Control-Allow-Headers "Content-Type, Authorization" always; + if ($request_method = OPTIONS) { + return 204; + } + } + + # Beacon Atlas agent listing (bounty #2127: GET /beacon/atlas) + location = /beacon/atlas { + proxy_pass http://127.0.0.1:8071/beacon/atlas; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_read_timeout 30s; + add_header Access-Control-Allow-Origin "*" always; + add_header Access-Control-Allow-Methods "GET, OPTIONS" always; + add_header Access-Control-Allow-Headers "Content-Type, Authorization" always; + if ($request_method = OPTIONS) { + return 204; + } + } + # BEP-2: External Agent Relay endpoints # Beacon SEO: Agent profiles, directory, sitemap, llms.txt location /beacon/agent/ { diff --git a/tests/test_rustchain_org_nginx_config.py b/tests/test_rustchain_org_nginx_config.py index 2cf968cc5..369630e01 100644 --- a/tests/test_rustchain_org_nginx_config.py +++ b/tests/test_rustchain_org_nginx_config.py @@ -26,3 +26,25 @@ def test_rustchain_org_nginx_proxies_ready_and_api_nodes(): assert api_nodes_locations == 2 assert config.count("proxy_pass http://127.0.0.1:8099/ready;") == 2 assert config.count("proxy_pass http://127.0.0.1:8099/api/nodes;") == 2 + + +def test_rustchain_org_nginx_beacon_join_routed_to_atlas_in_all_server_blocks(): + """Bounty #2127: POST /beacon/join must reach the Atlas API on 8071.""" + config = (ROOT / "site" / "nginx-rustchain-org.conf").read_text(encoding="utf-8") + + join_locations = config.count("location = /beacon/join {") + + assert join_locations == 2 + assert config.count("proxy_pass http://127.0.0.1:8071/beacon/join;") == join_locations + assert config.count('add_header Access-Control-Allow-Methods "POST, OPTIONS" always;') >= join_locations + + +def test_rustchain_org_nginx_beacon_atlas_routed_to_atlas_in_all_server_blocks(): + """Bounty #2127: GET /beacon/atlas must reach the Atlas API on 8071.""" + config = (ROOT / "site" / "nginx-rustchain-org.conf").read_text(encoding="utf-8") + + atlas_locations = config.count("location = /beacon/atlas {") + + assert atlas_locations == 2 + assert config.count("proxy_pass http://127.0.0.1:8071/beacon/atlas;") == atlas_locations + assert config.count('add_header Access-Control-Allow-Methods "GET, OPTIONS" always;') >= atlas_locations