7
7
"os"
8
8
9
9
"github.com/gofiber/fiber/v2"
10
- "github.com/joho/godotenv "
10
+ "github.com/gofiber/fiber/v2/middleware/cors "
11
11
"go.mongodb.org/mongo-driver/bson"
12
12
"go.mongodb.org/mongo-driver/bson/primitive"
13
13
"go.mongodb.org/mongo-driver/mongo"
@@ -27,10 +27,10 @@ func main() {
27
27
28
28
if os .Getenv ("ENV" ) != "production" {
29
29
// Load the .env file if not in production
30
- err := godotenv .Load (".env" )
31
- if err != nil {
32
- log .Fatal ("Error loading .env file:" , err )
33
- }
30
+ // err := godotenv.Load(".env")
31
+ // if err != nil {
32
+ // log.Fatal("Error loading .env file:", err)
33
+ // }
34
34
}
35
35
36
36
MONGODB_URI := os .Getenv ("MONGODB_URI" )
@@ -54,10 +54,10 @@ func main() {
54
54
55
55
app := fiber .New ()
56
56
57
- // app.Use(cors.New(cors.Config{
58
- // AllowOrigins: "http://localhost:5173",
59
- // AllowHeaders: "Origin,Content-Type,Accept",
60
- // }))
57
+ app .Use (cors .New (cors.Config {
58
+ AllowOrigins : "http://localhost:5173" ,
59
+ AllowHeaders : "Origin,Content-Type,Accept" ,
60
+ }))
61
61
62
62
app .Get ("/api/todos" , getTodos )
63
63
app .Post ("/api/todos" , createTodo )
0 commit comments