config logging. compose.yml
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
build: ./go-backend
|
build: .
|
||||||
container_name: carsharingBackend
|
container_name: carsharingBackend
|
||||||
ports:
|
ports:
|
||||||
- "8080:8080"
|
- "8080:8080"
|
||||||
@@ -95,9 +95,9 @@ var environmentOptions map[string]bool = map[string]bool{
|
|||||||
// It also generates JWT and CSRF secrets. Returns a Config pointer or an error if any step fails.
|
// It also generates JWT and CSRF secrets. Returns a Config pointer or an error if any step fails.
|
||||||
func LoadConfig() {
|
func LoadConfig() {
|
||||||
CFGPath = os.Getenv("CONFIG_FILE_PATH")
|
CFGPath = os.Getenv("CONFIG_FILE_PATH")
|
||||||
logger.Info.Printf("Config file environment: %v", CFGPath)
|
|
||||||
readFile(&CFG)
|
readFile(&CFG)
|
||||||
readEnv(&CFG)
|
readEnv(&CFG)
|
||||||
|
logger.Info.Printf("Config file environment: %v", CFGPath)
|
||||||
csrfSecret, err := utils.GenerateRandomString(32)
|
csrfSecret, err := utils.GenerateRandomString(32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error.Fatalf("could not generate CSRF secret: %v", err)
|
logger.Error.Fatalf("could not generate CSRF secret: %v", err)
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package middlewares
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"GoMembership/internal/config"
|
"GoMembership/internal/config"
|
||||||
"GoMembership/pkg/logger"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/gin-contrib/cors"
|
"github.com/gin-contrib/cors"
|
||||||
@@ -10,13 +9,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func CORSMiddleware() gin.HandlerFunc {
|
func CORSMiddleware() gin.HandlerFunc {
|
||||||
logger.Info.Print("Applying CORS")
|
|
||||||
return cors.New(cors.Config{
|
return cors.New(cors.Config{
|
||||||
AllowOrigins: strings.Split(config.Site.AllowOrigins, ","),
|
AllowOrigins: strings.Split(config.Site.AllowOrigins, ","),
|
||||||
AllowMethods: []string{"GET", "POST", "PATCH", "PUT", "OPTIONS"},
|
AllowMethods: []string{"GET", "POST", "PATCH", "PUT", "OPTIONS"},
|
||||||
AllowHeaders: []string{"Origin", "Content-Type", "Accept", "Authorization", "X-Requested-With", "X-CSRF-Token"},
|
AllowHeaders: []string{"Origin", "Content-Type", "Accept", "Authorization", "X-Requested-With", "X-CSRF-Token"},
|
||||||
ExposeHeaders: []string{"Content-Length"},
|
ExposeHeaders: []string{"Content-Length"},
|
||||||
AllowCredentials: true,
|
AllowCredentials: true,
|
||||||
|
AllowPrivateNetwork: true,
|
||||||
MaxAge: 12 * 60 * 60, // 12 hours
|
MaxAge: 12 * 60 * 60, // 12 hours
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user