Updated backend

This commit is contained in:
Patrick Alvin Alcala 2026-02-27 19:34:03 +08:00
parent 8e9b6048dd
commit 0dfa74b76f

View file

@ -30,9 +30,10 @@ func getCORSConfig(env string) cors.Config {
switch env { switch env {
case "dev": case "dev":
return cors.Config{ return cors.Config{
AllowOrigins: []string{"http://localhost:5173"}, AllowOrigins: []string{"http://localhost:5173"},
AllowMethods: []string{"GET", "POST", "OPTIONS", "DELETE"}, AllowMethods: []string{"GET", "POST", "OPTIONS", "DELETE"},
AllowHeaders: []string{"Origin", "OCBO-Token", "Content-Length", "Content-Type", "X-Server"}, // 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,
} }
@ -2492,5 +2493,49 @@ func connect() {
} }
}) })
router.DELETE("/api/delete-esigntransactions", func(c *gin.Context) {
type DeleteOPLocal struct {
Data string `json:"data"`
}
var deleteOpLocal DeleteOPLocal
if err := c.ShouldBindJSON(&deleteOpLocal); err != nil {
c.String(http.StatusBadRequest, "Invalid request body")
return
}
c.Writer.Header().Set("X-XSS-Protection", "1; mode=block")
c.Writer.Header().Set("X-Content-Type-Options", "nosniff")
c.Writer.Header().Set("X-DNS-Prefetch-Control", "off")
c.Writer.Header().Set("X-Frame-Options", "DENY")
c.Writer.Header().Set("X-Download-Options", "noopen")
c.Writer.Header().Set("Referrer-Policy", "no-referrer")
c.Writer.Header().Set("Content-Security-Policy", "default-src 'self'; img-src 'self';")
c.Writer.Header().Set("X-Server", "OCBO Server")
dbpost, err := dbpop.Prepare("DELETE FROM esign_transactions WHERE referenceNo = ?")
if err != nil {
c.AbortWithError(http.StatusInternalServerError, err)
c.String(http.StatusInternalServerError, "Internal Server Error")
return
}
defer dbpost.Close()
exec, err := dbpost.Exec(deleteOpLocal.Data)
if err != nil {
panic(err.Error())
}
affect, err := exec.RowsAffected()
if err != nil {
panic(err.Error())
}
if affect > 0 {
c.String(http.StatusOK, "Success on Deleting eSign Transactions")
} else {
c.String(http.StatusInternalServerError, "Failed on Deleting eSign Transactions")
}
})
router.Run(":4320") router.Run(":4320")
} }