From b3c3faa06defa4b0102a8638693146aa9e6fec77 Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Sun, 22 Mar 2026 02:35:06 -0400 Subject: [PATCH] Add optional API key support for server authentication in inventoryWebBridge --- inventoryWebBridge.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/inventoryWebBridge.lua b/inventoryWebBridge.lua index 2fc8aad..acf888b 100644 --- a/inventoryWebBridge.lua +++ b/inventoryWebBridge.lua @@ -22,6 +22,7 @@ local ORDER_CHANNEL = 4201 ------------------------------------------------- local CONFIG_FILE = ".webbridge_config" +local API_KEY = nil -- optional API key for server auth local function loadConfig() if fs.exists(CONFIG_FILE) then @@ -47,7 +48,6 @@ local latestState = nil -- last broadcast from master local modem = nil local modemName = nil local running = true -local API_KEY = nil -- optional API key for server auth ------------------------------------------------- -- Find modem @@ -75,7 +75,7 @@ local function httpPost(path, body) local headers = { ["Content-Type"] = "application/json" } if API_KEY then headers["Authorization"] = "Bearer " .. API_KEY end - local ok, err = pcall(function() + local ok, result = pcall(function() local response = http.post(url, data, headers) if response then local responseData = response.readAll() @@ -84,10 +84,10 @@ local function httpPost(path, body) end end) - if not ok then - -- Silent fail, will retry - return nil + if ok then + return result end + return nil end local function httpGet(path)