diff --git a/backend/main.go b/backend/main.go index 491f66b..cb26b7e 100644 --- a/backend/main.go +++ b/backend/main.go @@ -30,16 +30,17 @@ func getCORSConfig(env string) cors.Config { case "dev": return cors.Config{ AllowOrigins: []string{"http://localhost:5173"}, - AllowMethods: []string{"GET", "POST"}, - AllowHeaders: []string{"Origin", "OCBO-Token", "Content-Length", "Content-Type"}, + AllowMethods: []string{"GET", "POST", "OPTIONS"}, + AllowHeaders: []string{"Origin", "OCBO-Token", "Content-Length", "Content-Type", "X-Server"}, ExposeHeaders: []string{"Content-Length"}, AllowCredentials: true, } case "prod": return cors.Config{ - AllowOrigins: []string{"https://ocboapps.davaocity.gov.ph"}, - AllowMethods: []string{"GET", "POST"}, - AllowHeaders: []string{"Origin", "OCBO-Token", "Content-Length", "Content-Type"}, + AllowOrigins: []string{"https://ocboapps.davaocity.gov.ph", "https://esign.patalcala.com"}, + AllowMethods: []string{"GET", "POST", "OPTIONS"}, + // AllowHeaders: []string{"Origin", "OCBO-Token", "Content-Length", "Content-Type", "X-Server", "Authorization"}, + AllowHeaders: []string{"*"}, ExposeHeaders: []string{"Content-Length"}, AllowCredentials: true, } @@ -83,6 +84,7 @@ func connect() { router := gin.Default() router.Use(cors.New(getCORSConfig(env))) + // router.Use(cors.Default()) router.StaticFile("/", "static/index.html") router.StaticFile("/esign.webp", "static/esign.webp") @@ -1363,7 +1365,7 @@ func connect() { array := []string{} array2 := []string{} - results, err := db.Query(`SELECT IFNULL(referenceNo, '') AS result, IFNULL(date_signed, '') AS result2 FROM esign_transactions WHERE esignid = (SELECT esignid FROM esign WHERE employeeid = (SELECT employeeid FROM employee WHERE employeename = ?))`, data) + results, err := db.Query(`SELECT IFNULL(referenceNo, '') AS result, IFNULL(DATE_FORMAT(date_signed, '%M %e, %Y'), '') AS result2 FROM esign_transactions WHERE esignid = (SELECT esignid FROM esign WHERE employeeid = (SELECT employeeid FROM employee WHERE employeename = ?))`, data) if err != nil { c.AbortWithError(http.StatusBadRequest, err) c.String(http.StatusBadRequest, err.Error()) @@ -1392,7 +1394,7 @@ func connect() { return } c.JSON(http.StatusOK, gin.H{ - "result": result, + "result": result, }) }