From 09a151ead31fa3b912e0540f981aafd16089c462 Mon Sep 17 00:00:00 2001 From: niobium Date: Sat, 14 Sep 2019 17:11:16 +0200 Subject: [PATCH] nui/resources: add secure origin support for NUI RPC scheme As posted on https://forum.fivem.net/t/788942 by a user. --- code/components/nui-resources/src/RPCSchemeHandler.cpp | 2 +- code/components/nui-resources/src/ResourceUI.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/code/components/nui-resources/src/RPCSchemeHandler.cpp b/code/components/nui-resources/src/RPCSchemeHandler.cpp index 394fba60fe..e201f761f1 100644 --- a/code/components/nui-resources/src/RPCSchemeHandler.cpp +++ b/code/components/nui-resources/src/RPCSchemeHandler.cpp @@ -210,7 +210,7 @@ static InitFunction initFunction([] () { OnSchemeCreateRequest.Connect([] (const char* name, CefRefPtr request, CefRefPtr& handler) { - if (!strcmp(name, "http")) + if (!strcmp(name, "http") || !strcmp(name, "https")) { handler = new RPCResourceHandler(); } diff --git a/code/components/nui-resources/src/ResourceUI.cpp b/code/components/nui-resources/src/ResourceUI.cpp index 9eed8afb31..978a7e28ac 100644 --- a/code/components/nui-resources/src/ResourceUI.cpp +++ b/code/components/nui-resources/src/ResourceUI.cpp @@ -59,6 +59,7 @@ bool ResourceUI::Create() auto resourceName = m_resource->GetName(); std::transform(resourceName.begin(), resourceName.end(), resourceName.begin(), ::ToLower); CefRegisterSchemeHandlerFactory("http", resourceName, Instance::Get()); + CefRegisterSchemeHandlerFactory("https", resourceName, Instance::Get()); // create the NUI frame std::string path = "nui://" + m_resource->GetName() + "/" + pageName; @@ -66,6 +67,7 @@ bool ResourceUI::Create() // add a cross-origin entry to allow fetching the callback handler CefAddCrossOriginWhitelistEntry(va("nui://%s", m_resource->GetName().c_str()), "http", m_resource->GetName(), true); + CefAddCrossOriginWhitelistEntry(va("nui://%s", m_resource->GetName().c_str()), "https", m_resource->GetName(), true); return true; }