From abae80f410ef3678641c3396e134685cc4f7c8bd Mon Sep 17 00:00:00 2001 From: redsolver Date: Thu, 16 May 2024 13:13:07 +0200 Subject: [PATCH] fix loading web apps on subdomain, closes #22 --- lib/http_api/http_api.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/http_api/http_api.dart b/lib/http_api/http_api.dart index bf2d2b9..86c826b 100644 --- a/lib/http_api/http_api.dart +++ b/lib/http_api/http_api.dart @@ -895,8 +895,7 @@ class HttpAPIServer { final String? domain = node.config['http']?['api']?['domain']; if (domain != null) { - if (uri.host == 'localhost') { - } else if (uri.host == domain) { + if (uri.host == domain) { if (request.uri.path == '/s5/p2p') { final socket = await WebSocketTransformer.upgrade(request); @@ -916,6 +915,8 @@ class HttpAPIServer { } else if (uri.host == 'docs.$domain') { cid = CID.decode('zrjD7xwmgP8U6hquPUtSRcZP1J1LvksSwTq4CPZ2ck96FHu'); checkAuth = false; + } else if ('.${uri.host}'.endsWith('.$domain')) { + cid = CID.decode(uri.host.split('.').first); } else if (!('.${uri.host}').endsWith('.$domain')) { final cidStr = await node.resolveName(uri.host); cid = CID.decode(cidStr);