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":
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())