Skip to content

Commit f6db957

Browse files
committed
fix: http server url
1 parent b02a7ab commit f6db957

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

internal/config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type (
2727

2828
// Server contains the configurations for both HTTP and gRPC servers.
2929
Server struct {
30+
Host string `mapstructure:"host"` // Host for servers
3031
HTTP HTTP `mapstructure:"http"` // HTTP server configuration
3132
GRPC GRPC `mapstructure:"grpc"` // gRPC server configuration
3233
NameOverride string `mapstructure:"name_override"`
@@ -44,7 +45,6 @@ type (
4445

4546
// GRPC contains configuration for the gRPC server.
4647
GRPC struct {
47-
Host string `mapstructure:"host"` // Host for the gRPC server
4848
Port string `mapstructure:"port"` // Port for the gRPC server
4949
TLSConfig TLSConfig `mapstructure:"tls"` // TLS configuration for the gRPC server
5050
}
@@ -284,6 +284,7 @@ func DefaultConfig() *Config {
284284
AccountID: "",
285285
Server: Server{
286286
NameOverride: "",
287+
Host: "127.0.0.1",
287288
HTTP: HTTP{
288289
Enabled: true,
289290
Port: "3476",
@@ -294,7 +295,6 @@ func DefaultConfig() *Config {
294295
CORSAllowedHeaders: []string{"*"},
295296
},
296297
GRPC: GRPC{
297-
Host: "127.0.0.1",
298298
Port: "3478",
299299
TLSConfig: TLSConfig{
300300
Enabled: false,

internal/servers/server.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ func (s *Container) Run(
269269
options = append(options, grpc.WithTransportCredentials(insecure.NewCredentials()))
270270
}
271271

272-
targetAddr := net.JoinHostPort(srv.GRPC.Host, srv.GRPC.Port) // gRPC server address
273-
conn, err := grpc.NewClient(targetAddr, options...) // Create gRPC client connection
272+
targetAddr := net.JoinHostPort(srv.Host, srv.GRPC.Port) // gRPC server address
273+
conn, err := grpc.NewClient(targetAddr, options...) // Create gRPC client connection
274274
if err != nil {
275275
return err
276276
}
@@ -340,9 +340,10 @@ func (s *Container) Run(
340340
}, // Methods configured
341341
}).Handler(mux) // CORS handler created
342342

343-
httpServer = &http.Server{ // HTTP server configuration
344-
Addr: targetAddr, // Server address
345-
Handler: corsHandler, // CORS handler
343+
httpTargetAddr := net.JoinHostPort(srv.Host, srv.HTTP.Port) // HTTP server address
344+
httpServer = &http.Server{ // HTTP server configuration
345+
Addr: httpTargetAddr, // Server address
346+
Handler: corsHandler, // CORS handler
346347
ReadHeaderTimeout: 5 * time.Second,
347348
}
348349

0 commit comments

Comments
 (0)