..
Viewing
main.go
36 lines (30 loc) • 850.0 B
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 | package main
import (
"log"
"os"
"pagoda/database"
"pagoda/router"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/joho/godotenv"
)
func init() {
// Load the .env file
godotenv.Load()
}
func main() {
app := fiber.New()
app.Use(cors.New(cors.Config{
AllowHeaders: "Origin,Content-Type,Accept,Content-Length,Accept-Language,Accept-Encoding,Connection,Access-Control-Allow-Origin,Authorization",
AllowOrigins: "http://localhost:5173,https://pagoda.neocities.org",
AllowCredentials: true,
AllowMethods: "GET,POST,HEAD,PUT,DELETE,PATCH,OPTIONS",
ExposeHeaders: "Set-Cookie",
}))
app.Use(logger.New())
router.Initialize(app)
database.ConnectDB()
database.ConnectRedis()
log.Fatal(app.Listen(":" + os.Getenv("PORT")))
}
|
|