swiftdockervapor

Changing hostname and port with Vapor 3


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?


Solution

  • 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.