fix desktop

This commit is contained in:
2025-10-03 16:51:29 +06:00
parent cce64b19e8
commit e28d0ec77e
6 changed files with 249 additions and 212 deletions

View File

@@ -43,11 +43,16 @@ func runServe(cmd *cobra.Command, args []string) error {
port = "8888"
}
host := os.Getenv("GO_KNOCKER_SERVE_HOST")
if strings.TrimSpace(port) == "" {
host = ""
}
r := gin.Default()
// CORS: разрешаем для локальной разработки
r.Use(cors.New(cors.Config{
AllowOrigins: []string{"http://localhost:4200", "http://127.0.0.1:8888", "http://localhost:8888"},
AllowOrigins: []string{"http://localhost:4200", "http://127.0.0.1:8888", "http://localhost:" + port},
AllowMethods: []string{"GET", "POST", "OPTIONS"},
AllowHeaders: []string{"Authorization", "Content-Type"},
AllowCredentials: true,
@@ -65,6 +70,6 @@ func runServe(cmd *cobra.Command, args []string) error {
setupCryptoRoutes(api, passHash)
setupStaticRoutes(r, embeddedFS)
fmt.Printf("Serving on :%s\n", port)
return r.Run(":" + port)
fmt.Printf("Serving on %s:%s\n", host, port)
return r.Run(host + ":" + port)
}