TERMINALDEV TERMINALDEV - 2 months ago 11
Swift Question

How to change IP of your server access from 0.0.0.0:8181 in Perfect 2.0?

I'm new to server side programming, Since Perfect is out for Swift i am trying to get started with it.

I started PerfectTemplate and it's working on http://0.0.0.0:8181 but not accessible using my public ip i.e. say for example http://123.45.67.89:8181

Answer

Command+Click property "serverPort" it will take you to the implementation of HTTPServer.swift. There is another property "serverAddress" which is set to "0.0.0.0" by default.

you can change this by adding the following line

server.serverAddress ="123.45.67.89"

just above where you set

server.serverPort = 8181