This commit is contained in:
Ybehrooz
2025-05-20 20:07:46 +03:30
parent 7bc33a8808
commit 965d6900be
7 changed files with 28 additions and 33 deletions

View File

@@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"main/db"
"main/handler"
"net/http"
@@ -72,6 +71,7 @@ func registerHnadler(w http.ResponseWriter, r *http.Request) {
_, err := db.UserCollection.InsertOne(context.TODO(), user)
if err != nil {
http.Error(w, `{"message": "Could not create user"}`, http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusCreated)
@@ -129,12 +129,12 @@ func main() {
//handler.RegsiterClusterRoute(router)
// Enable CORS
c := cors.New(cors.Options{
AllowedOrigins: []string{"*"}, // Allow all origins
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
Debug: true, // Enable debug logging
})
http.ListenAndServe("0.0.0.0:8082", c.Handler(router))