go-fuego / fuego

Golang Fuego - web framework generating OpenAPI 3 spec from source code
https://go-fuego.github.io/fuego/
MIT License
901 stars 43 forks source link

Setting fuego address will terminates server #223

Closed fyaacobseek closed 1 day ago

fyaacobseek commented 1 day ago

To Reproduce

Run the server with following code:

    s := fuego.NewServer(fuego.WithAddr("<your domain>:443"))

When I run my go program, it immediate terminate with no error.

image

Expected behavior

  1. The service will run & serve requests
  2. OpenAPI produced will point to the domain instead of localhost

Framework version (please check if it happens with the last Fuego version before posting):

github.com/go-fuego/fuego v0.14.0

Go version (please check if it happens with the last Go version before posting):

go 1.23.0

Additional context

I was checking ChatGPT, both http.ListenAndServe and http.ListenAndServeTLS do not accept domain name. From my testing, it only works when I provide localhost as host name.

fyaacobseek commented 1 day ago

From ChatGPT:

Go has to ensure the Domain Resolves to a Local IP. If fadhil-blog.dev is hosted on a remote server but resolves correctly, try setting the Go server to listen on :8080 instead of explicitly specifying the domain. This approach allows the server to respond to any incoming requests on that port, regardless of the hostname.

When I set 127.0.0.1 fadhil-blog.dev in my /etc/hosts file, the go program runs fine.

dylanhitt commented 1 day ago

Hey @fyaacobseek glad you figured this out. Just a note for you. When you go to host this application on a remote server you will need to set the IP address to either the server that is running the app or what many people will do is just set the app to listen on all interfaces with 0.0.0.0:8080