fixed headers bug

This commit is contained in:
akdeb 2026-01-07 17:14:42 +07:00
parent cf3a4cd07c
commit c339c6c6bd
2 changed files with 4 additions and 3 deletions

View file

@ -365,7 +365,8 @@ void websocketSetup(const String& server_domain, int port, const String& path)
{
const String headers =
"Authorization: Bearer " + String(authTokenGlobal) + "\r\n" +
"mac_address: " + WiFi.macAddress() + "\r\n";
"X-Wifi-Rssi: " + String(WiFi.RSSI()) + "\r\n" +
"X-Device-Mac: " + WiFi.macAddress();
xSemaphoreTake(wsMutex, portMAX_DELAY);

View file

@ -124,7 +124,7 @@ server.on("upgrade", async (req, socket, head) => {
const {
authorization: authHeader,
"x-wifi-rssi": rssi,
mac_address,
"x-device-mac": deviceMac,
} = req.headers;
authToken = authHeader?.replace("Bearer ", "") ?? "";
const wifiStrength = parseInt(rssi as string); // Convert to number
@ -143,7 +143,7 @@ server.on("upgrade", async (req, socket, head) => {
user = await authenticateUser(supabase, authToken as string);
const expectedMac = user.device?.mac_address;
if (mac_address && mac_address !== expectedMac) {
if (deviceMac && deviceMac !== expectedMac) {
socket.write("HTTP/1.1 401 Unauthorized\r\n\r\n");
socket.destroy();
return;