Skip to content

Commit

Permalink
fix(nui/core): set user-agent for imgur URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
mninc committed Feb 29, 2024
1 parent 8011142 commit d0ec48a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions code/components/nui-core/src/NUIClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,25 @@ auto NUIClient::OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser, CefRefPtr<Ce
}
}

// Imgur started blocking CitizenFX in the user-agent
{
CefURLParts parts;
if (CefParseURL(request->GetURL(), parts))
{
auto hostString = CefString(&parts.host).ToString();

if (boost::algorithm::ends_with(hostString, "imgur.com"))
{
CefRequest::HeaderMap headers;
request->GetHeaderMap(headers);

headers.erase("User-Agent");
headers.emplace("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36");
request->SetHeaderMap(headers);
}
}
}

#if !defined(_DEBUG)
if (frame->IsMain())
{
Expand Down

0 comments on commit d0ec48a

Please sign in to comment.