Updated backend

This commit is contained in:
Patrick Alvin Alcala 2026-02-04 18:38:38 +08:00
parent 19089efb8f
commit edc40aea6a

View file

@ -30,16 +30,17 @@ func getCORSConfig(env string) cors.Config {
case "dev": case "dev":
return cors.Config{ return cors.Config{
AllowOrigins: []string{"http://localhost:5173"}, AllowOrigins: []string{"http://localhost:5173"},
AllowMethods: []string{"GET", "POST"}, AllowMethods: []string{"GET", "POST", "OPTIONS"},
AllowHeaders: []string{"Origin", "OCBO-Token", "Content-Length", "Content-Type"}, AllowHeaders: []string{"Origin", "OCBO-Token", "Content-Length", "Content-Type", "X-Server"},
ExposeHeaders: []string{"Content-Length"}, ExposeHeaders: []string{"Content-Length"},
AllowCredentials: true, AllowCredentials: true,
} }
case "prod": case "prod":
return cors.Config{ return cors.Config{
AllowOrigins: []string{"https://ocboapps.davaocity.gov.ph"}, AllowOrigins: []string{"https://ocboapps.davaocity.gov.ph", "https://esign.patalcala.com"},
AllowMethods: []string{"GET", "POST"}, AllowMethods: []string{"GET", "POST", "OPTIONS"},
AllowHeaders: []string{"Origin", "OCBO-Token", "Content-Length", "Content-Type"}, // AllowHeaders: []string{"Origin", "OCBO-Token", "Content-Length", "Content-Type", "X-Server", "Authorization"},
AllowHeaders: []string{"*"},
ExposeHeaders: []string{"Content-Length"}, ExposeHeaders: []string{"Content-Length"},
AllowCredentials: true, AllowCredentials: true,
} }
@ -83,6 +84,7 @@ func connect() {
router := gin.Default() router := gin.Default()
router.Use(cors.New(getCORSConfig(env))) router.Use(cors.New(getCORSConfig(env)))
// router.Use(cors.Default())
router.StaticFile("/", "static/index.html") router.StaticFile("/", "static/index.html")
router.StaticFile("/esign.webp", "static/esign.webp") router.StaticFile("/esign.webp", "static/esign.webp")
@ -1363,7 +1365,7 @@ func connect() {
array := []string{} array := []string{}
array2 := []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 { if err != nil {
c.AbortWithError(http.StatusBadRequest, err) c.AbortWithError(http.StatusBadRequest, err)
c.String(http.StatusBadRequest, err.Error()) c.String(http.StatusBadRequest, err.Error())
@ -1392,7 +1394,7 @@ func connect() {
return return
} }
c.JSON(http.StatusOK, gin.H{ c.JSON(http.StatusOK, gin.H{
"result": result, "result": result,
}) })
} }