mirror of
https://github.com/CannedNet/CannedNet.git
synced 2026-10-25 15:09:23 -07:00
OKAY NOW IT ACTUALLY WORKS
This commit is contained in:
@@ -1,38 +1,38 @@
|
||||
{
|
||||
"Accounts": "https://cannednet.lapis.codes/accounts",
|
||||
"AI": "https://cannednet.lapis.codes/ai",
|
||||
"API": "https://cannednet.lapis.codes/api",
|
||||
"Auth": "https://cannednet.lapis.codes/auth",
|
||||
"BugReporting": "https://cannednet.lapis.codes/bugreporting",
|
||||
"Cards": "https://cannednet.lapis.codes/cards",
|
||||
"CDN": "https://cannednet.lapis.codes/cdn",
|
||||
"Chat": "https://cannednet.lapis.codes/chat",
|
||||
"Clubs": "https://cannednet.lapis.codes/clubs",
|
||||
"CMS": "https://cannednet.lapis.codes/cms",
|
||||
"Commerce": "https://cannednet.lapis.codes/commerce",
|
||||
"Data": "https://cannednet.lapis.codes/data",
|
||||
"DataCollection": "https://cannednet.lapis.codes/datacollection",
|
||||
"Discovery": "https://cannednet.lapis.codes/discovery",
|
||||
"Econ": "https://cannednet.lapis.codes/econ",
|
||||
"GameLogs": "https://cannednet.lapis.codes/gamelogs",
|
||||
"Geo": "https://cannednet.lapis.codes/geo",
|
||||
"Images": "https://cannednet.lapis.codes/img",
|
||||
"Leaderboard": "https://cannednet.lapis.codes/leaderboard",
|
||||
"Link": "https://cannednet.lapis.codes/link",
|
||||
"Lists": "https://cannednet.lapis.codes/lists",
|
||||
"Matchmaking": "https://cannednet.lapis.codes/match",
|
||||
"Moderation": "https://cannednet.lapis.codes/moderation",
|
||||
"Notifications": "https://cannednet.lapis.codes",
|
||||
"PlatformNotifications": "https://cannednet.lapis.codes",
|
||||
"PlayerSettings": "https://cannednet.lapis.codes/playersettings",
|
||||
"RoomComments": "https://cannednet.lapis.codes/roomcomments",
|
||||
"RoomieIntegrations": "https://cannednet.lapis.codes/roomieintegrations",
|
||||
"Rooms": "https://cannednet.lapis.codes/rooms",
|
||||
"Storage": "https://cannednet.lapis.codes/storage",
|
||||
"Strings": "https://cannednet.lapis.codes/strings",
|
||||
"StringsCDN": "https://cannednet.lapis.codes/stringscdn",
|
||||
"Studio": "https://cannednet.lapis.codes/studio",
|
||||
"Thorn": "https://cannednet.lapis.codes/thorn",
|
||||
"Videos": "https://cannednet.lapis.codes/videos",
|
||||
"WWW": "https://cannednet.lapis.codes"
|
||||
}
|
||||
"Accounts": "http://localhost:5000/accounts",
|
||||
"AI": "http://localhost:5000/ai",
|
||||
"API": "http://localhost:5000/api",
|
||||
"Auth": "http://localhost:5000/auth",
|
||||
"BugReporting": "http://localhost:5000/bugreporting",
|
||||
"Cards": "http://localhost:5000/cards",
|
||||
"CDN": "http://localhost:5000/cdn",
|
||||
"Chat": "http://localhost:5000/chat",
|
||||
"Clubs": "http://localhost:5000/clubs",
|
||||
"CMS": "http://localhost:5000/cms",
|
||||
"Commerce": "http://localhost:5000/commerce",
|
||||
"Data": "http://localhost:5000/data",
|
||||
"DataCollection": "http://localhost:5000/datacollection",
|
||||
"Discovery": "http://localhost:5000/discovery",
|
||||
"Econ": "http://localhost:5000/econ",
|
||||
"GameLogs": "http://localhost:5000/gamelogs",
|
||||
"Geo": "http://localhost:5000/geo",
|
||||
"Images": "http://localhost:5000/img",
|
||||
"Leaderboard": "http://localhost:5000/leaderboard",
|
||||
"Link": "http://localhost:5000/link",
|
||||
"Lists": "http://localhost:5000/lists",
|
||||
"Matchmaking": "http://localhost:5000/match",
|
||||
"Moderation": "http://localhost:5000/moderation",
|
||||
"Notifications": "http://localhost:5000",
|
||||
"PlatformNotifications": "http://localhost:5000",
|
||||
"PlayerSettings": "http://localhost:5000/playersettings",
|
||||
"RoomComments": "http://localhost:5000/roomcomments",
|
||||
"RoomieIntegrations": "http://localhost:5000/roomieintegrations",
|
||||
"Rooms": "http://localhost:5000/rooms",
|
||||
"Storage": "http://localhost:5000/storage",
|
||||
"Strings": "http://localhost:5000/strings",
|
||||
"StringsCDN": "http://localhost:5000/stringscdn",
|
||||
"Studio": "http://localhost:5000/studio",
|
||||
"Thorn": "http://localhost:5000/thorn",
|
||||
"Videos": "http://localhost:5000/videos",
|
||||
"WWW": "http://localhost:5000"
|
||||
}
|
||||
|
||||
@@ -51,40 +51,37 @@ public class ConfigService
|
||||
if (endpoints == null || endpoints.Count == 0)
|
||||
return;
|
||||
|
||||
var currentBase = DetectBaseUrl(endpoints);
|
||||
if (currentBase == null)
|
||||
if (!Uri.TryCreate(configBase + "/", UriKind.Absolute, out var configUri))
|
||||
return;
|
||||
|
||||
if (string.Equals(currentBase, configBase, StringComparison.OrdinalIgnoreCase))
|
||||
return;
|
||||
var configOrigin = $"{configUri.Scheme}://{configUri.Host}{(configUri.IsDefaultPort ? "" : $":{configUri.Port}")}";
|
||||
|
||||
var updated = new Dictionary<string, string>(endpoints.Count);
|
||||
var changed = false;
|
||||
|
||||
foreach (var (key, url) in endpoints)
|
||||
{
|
||||
if (url.StartsWith(currentBase, StringComparison.OrdinalIgnoreCase))
|
||||
if (string.IsNullOrEmpty(url) || !Uri.TryCreate(url, UriKind.Absolute, out var uri))
|
||||
{
|
||||
var path = url[currentBase.Length..];
|
||||
updated[key] = configBase + path;
|
||||
updated[key] = url;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
|
||||
var urlOrigin = $"{uri.Scheme}://{uri.Host}{(uri.IsDefaultPort ? "" : $":{uri.Port}")}";
|
||||
if (string.Equals(urlOrigin, configOrigin, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
updated[key] = url;
|
||||
}
|
||||
else
|
||||
{
|
||||
var path = url[urlOrigin.Length..];
|
||||
updated[key] = configOrigin + path;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
File.WriteAllText(EndpointsPath, JsonSerializer.Serialize(updated, Indented));
|
||||
}
|
||||
|
||||
private static string? DetectBaseUrl(Dictionary<string, string> endpoints)
|
||||
{
|
||||
foreach (var url in endpoints.Values)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
continue;
|
||||
if (Uri.TryCreate(url, UriKind.Absolute, out var uri))
|
||||
return $"{uri.Scheme}://{uri.Host}{(uri.IsDefaultPort ? "" : $":{uri.Port}")}";
|
||||
}
|
||||
return null;
|
||||
if (changed)
|
||||
File.WriteAllText(EndpointsPath, JsonSerializer.Serialize(updated, Indented));
|
||||
}
|
||||
|
||||
private static AppConfig CreateDefaultConfig()
|
||||
|
||||
Reference in New Issue
Block a user