From a0550950e3e8d63fe2d2afdd39337f4ad26b7bca Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Fri, 12 Jun 2026 19:24:06 +0500 Subject: [PATCH] change(ApiHeaderProxy): include Flame API key for CDN downloads Signed-off-by: Octol1ttle (cherry picked from commit b387a1f79314245274500beecf54df8e55a9c84e) --- buildconfig/BuildConfig.h | 2 ++ launcher/net/ApiHeaderProxy.h | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/buildconfig/BuildConfig.h b/buildconfig/BuildConfig.h index d430622bc..a5851bfba 100644 --- a/buildconfig/BuildConfig.h +++ b/buildconfig/BuildConfig.h @@ -194,8 +194,10 @@ class Config { QString MODRINTH_STAGING_URL = "https://staging-api.modrinth.com/v2"; QString MODRINTH_PROD_URL = "https://api.modrinth.com/v2"; QStringList MODRINTH_MRPACK_HOSTS{ "cdn.modrinth.com", "github.com", "raw.githubusercontent.com", "gitlab.com" }; + QString MODRINTH_DOWNLOAD_HOST = "cdn.modrinth.com"; QString FLAME_BASE_URL = "https://api.curseforge.com/v1"; + QString FLAME_DOWNLOAD_HOST = "edge.forgecdn.net"; QString versionString() const; /** diff --git a/launcher/net/ApiHeaderProxy.h b/launcher/net/ApiHeaderProxy.h index d48379617..d12287a4e 100644 --- a/launcher/net/ApiHeaderProxy.h +++ b/launcher/net/ApiHeaderProxy.h @@ -61,17 +61,19 @@ class ApiHeaderProxy : public HeaderProxy { QList headers(const QNetworkRequest& request) const override { QList hdrs; - if (APPLICATION->capabilities() & Application::SupportsFlame && request.url().host() == QUrl(BuildConfig.FLAME_BASE_URL).host()) { + const auto host = request.url().host(); + + if (APPLICATION->capabilities() & Application::SupportsFlame && + (host == QUrl(BuildConfig.FLAME_BASE_URL).host() || host == BuildConfig.FLAME_DOWNLOAD_HOST)) { hdrs.append({ .headerName = "x-api-key", .headerValue = APPLICATION->getFlameAPIKey().toUtf8() }); - } else if (request.url().host() == QUrl(BuildConfig.MODRINTH_PROD_URL).host() || - request.url().host() == QUrl(BuildConfig.MODRINTH_STAGING_URL).host()) { + } else if (host == QUrl(BuildConfig.MODRINTH_PROD_URL).host() || host == QUrl(BuildConfig.MODRINTH_STAGING_URL).host()) { QString token = APPLICATION->getModrinthAPIToken(); if (!token.isNull()) { hdrs.append({ .headerName = "Authorization", .headerValue = token.toUtf8() }); } } - if (request.url().host() == "cdn.modrinth.com" && !m_meta.isEmpty()) { + if (host == BuildConfig.MODRINTH_DOWNLOAD_HOST && !m_meta.isEmpty()) { hdrs.append({ .headerName = "modrinth-download-meta", .headerValue = m_meta.toJson() }); } return hdrs;