The Config/server.json file doesn't seem to be read by Vapor 3, and as such I can't configure the hostname and port that a Vapor 3 app binds to.
Does Vapor 3 have a different method for this?
You can use NIOServerConfig.
let serverConfiure = NIOServerConfig.default(hostname: "0.0.0.0", port: 9090)
services.register(serverConfiure)
Vapor version is 3.0.3
Currently, you can set the port and hostname when running your server:
swift run Run --hostname 0.0.0.0 --port 9000
There appears to be struct-based configuration for EngineServer
but I don’t think it is configurable at run time just yet. The last time the Vapor developer answered this question (on their Slack) the command-line argument method was the suggested one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With