Adding files to the HTTP server

At the minute the only way I’ve managed to expose files on the server (like the info.json and players.json files) is to create a new HTTP server and handle the requests through that.

I think it’d be nicer and simpler if we could add files to the existing HTTP server that is created when the server is started.

I am doing this in FxServer. I might post how I am doing this as a tutorial

It’s not exactly the same thing but it’s close enough :smiley: https://runtime.fivem.net/doc/reference.html#_0xf5c6330c

How exactly can we use that function?

I tried this:

SetHttpHandler(function(req, res)
    CreateThread(function()
        Wait(1000)
        res.send("Hello there, " .. req.path:sub(2) .. "!")
    end)
end)

but when I navigate to the path curl -s http://localhost:30120/hmpf/dick it gets stuck fetching and doesn’t display anything.

and this code is in the client file of the resource called hmpf

check the runcode resource for an example

This topic was automatically closed after 3 days. New replies are no longer allowed.