feat: frontend
This commit is contained in:
22
api/corsmiddleware/cors_middleware.go
Normal file
22
api/corsmiddleware/cors_middleware.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package corsmiddleware
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func CORSMiddleware(c *gin.Context) {
|
||||
log.Printf("%s", c.Request.Method)
|
||||
c.Writer.Header().Set("Access-Control-Allow-Origin", "http://localhost:3000")
|
||||
c.Writer.Header().Set("Access-Control-Allow-Credentials", "true")
|
||||
c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With")
|
||||
c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS, GET, PUT, DELETE")
|
||||
|
||||
if c.Request.Method == "OPTIONS" {
|
||||
c.AbortWithStatus(204)
|
||||
return
|
||||
}
|
||||
|
||||
c.Next()
|
||||
}
|
||||
Reference in New Issue
Block a user