[Backport release-11.x] Include Flame API key in CDN downloads (#5689)
Some checks are pending
Nix / Build (aarch64-darwin) (push) Waiting to run
Nix / Build (x86_64-linux) (push) Waiting to run
Nix / Build (aarch64-linux) (push) Waiting to run

This commit is contained in:
Alexandru Ionut Tripon 2026-06-17 13:17:18 +03:00 committed by GitHub
commit 479d111482
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View file

@ -194,8 +194,10 @@ class Config {
QString MODRINTH_STAGING_URL = "https://staging-api.modrinth.com/v2"; QString MODRINTH_STAGING_URL = "https://staging-api.modrinth.com/v2";
QString MODRINTH_PROD_URL = "https://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" }; 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_BASE_URL = "https://api.curseforge.com/v1";
QString FLAME_DOWNLOAD_HOST = "edge.forgecdn.net";
QString versionString() const; QString versionString() const;
/** /**

View file

@ -61,17 +61,19 @@ class ApiHeaderProxy : public HeaderProxy {
QList<HeaderPair> headers(const QNetworkRequest& request) const override QList<HeaderPair> headers(const QNetworkRequest& request) const override
{ {
QList<HeaderPair> hdrs; QList<HeaderPair> 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() }); hdrs.append({ .headerName = "x-api-key", .headerValue = APPLICATION->getFlameAPIKey().toUtf8() });
} else if (request.url().host() == QUrl(BuildConfig.MODRINTH_PROD_URL).host() || } else if (host == QUrl(BuildConfig.MODRINTH_PROD_URL).host() || host == QUrl(BuildConfig.MODRINTH_STAGING_URL).host()) {
request.url().host() == QUrl(BuildConfig.MODRINTH_STAGING_URL).host()) {
QString token = APPLICATION->getModrinthAPIToken(); QString token = APPLICATION->getModrinthAPIToken();
if (!token.isNull()) { if (!token.isNull()) {
hdrs.append({ .headerName = "Authorization", .headerValue = token.toUtf8() }); 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() }); hdrs.append({ .headerName = "modrinth-download-meta", .headerValue = m_meta.toJson() });
} }
return hdrs; return hdrs;