Hammerspoon / hammerspoon

Staggeringly powerful macOS desktop automation with Lua
http://www.hammerspoon.org
MIT License
12.13k stars 586 forks source link

hs.httpserver not working on MacOS Sonoma 14.6.1 #3700

Closed hacker-DOM closed 1 month ago

hacker-DOM commented 1 month ago

Consider this code:


local http_server = hs.httpserver.new(false, false) -- ssl, bonjour

local function handle_request(method, path)
    print("Received request:", method, path)
    return 200, "Success", "text/plain"
end

http_server:setPort(1234):setName("test"):setCallback(handle_request):start()

When I go to http://localhost:1234, I would expect to see the log, but nothing happens.

I believe this should show me whether a program is listening on port 1234

❯ lsof -P -iTCP:1234 -sTCP:LISTEN

but again it is empty.

I am on Macos @ 14.6.1 and Hammerspoon @ 0.9.97. Maybe I have to give Hammerspoon additional permissions or something (I couldn't find anything).

Thank you!

hacker-DOM commented 1 month ago

It was being garbage collected.