This commit is contained in:
unknown
2025-05-11 20:18:33 +03:30
parent 61a9fbe9f2
commit 7bc33a8808
5 changed files with 119 additions and 19 deletions

16
main.go
View File

@@ -5,7 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"log"
"main/db"
"main/handler"
@@ -125,15 +125,17 @@ func main() {
router.HandleFunc("/register", registerHnadler)
router.HandleFunc("/login", loginHandler)
handler.RegsiterClusterRoute(router)
router.HandleFunc("/createcluster", handler.CreateClusterHandler)
//handler.RegsiterClusterRoute(router)
// Enable CORS
c := cors.New(cors.Options{
AllowedOrigins: []string{"http://localhost:4200", "*"}, // Angular app's origin
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE"},
AllowedHeaders: []string{"Content-Type"},
AllowedOrigins: []string{"*"}, // Allow all origins
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
AllowedHeaders: []string{"Content-Type", "Authorization", "X-Requested-With", "Accept", "Origin"},
ExposedHeaders: []string{"Content-Length"},
AllowCredentials: true,
Debug: true, // Enable debug logging
})
log.Fatal(http.ListenAndServe(":8082", c.Handler((router))))
http.ListenAndServe("0.0.0.0:8082", c.Handler(router))
}