]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
server: Ignore empty / non-existing `Origin` headers (#25756)
authorSebastian Dröge <redacted>
Thu, 16 Jul 2026 09:26:51 +0000 (12:26 +0300)
committerGitHub <redacted>
Thu, 16 Jul 2026 09:26:51 +0000 (12:26 +0300)
Otherwise this gives lots of unnecessary warnings:

  W srv    operator(): (CORS) skip non-localhost origin:

tools/server/server-http.cpp

index 24a38452aab73102185c5e0472d9086480cee931..783b01b82d11d876292430984f6cda54058c054c 100644 (file)
@@ -283,9 +283,9 @@ bool server_http_context::init(const common_params & params) {
         } else if (params.cors_origins == "localhost") {
             // special case: only reflect the Origin header if it is a localhost origin
             std::string origin = req.get_header_value("Origin");
-            if (origin_is_localhost(origin)) {
+            if (!origin.empty() && origin_is_localhost(origin)) {
                 res.set_header("Access-Control-Allow-Origin", origin);
-            } else {
+            } else if (!origin.empty()) {
                 SRV_WRN("(CORS) skip non-localhost origin: %s\n", origin.c_str());
             }
         } else {