Skip to content

Commit ecfa1e4

Browse files
committed
changed cors config -> now delete and patch request allowed
removed requirement of .env file
1 parent 66cf89e commit ecfa1e4

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
environment:
88
MONGODB_URI: <db_connection_string>
99
PORT: "5000"
10-
ENV: development
10+
ENV: production
1111
ports:
1212
- "5000:5000"
1313

server/main.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"os"
88

99
"github.com/gofiber/fiber/v2"
10-
"github.com/joho/godotenv"
10+
"github.com/gofiber/fiber/v2/middleware/cors"
1111
"go.mongodb.org/mongo-driver/bson"
1212
"go.mongodb.org/mongo-driver/bson/primitive"
1313
"go.mongodb.org/mongo-driver/mongo"
@@ -27,10 +27,10 @@ func main() {
2727

2828
if os.Getenv("ENV") != "production" {
2929
// 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+
// }
3434
}
3535

3636
MONGODB_URI := os.Getenv("MONGODB_URI")
@@ -54,10 +54,10 @@ func main() {
5454

5555
app := fiber.New()
5656

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+
}))
6161

6262
app.Get("/api/todos", getTodos)
6363
app.Post("/api/todos", createTodo)

0 commit comments

Comments
 (0)