Files
terminalShop/api/middleware/cors.go

20 lines
526 B
Go

package middleware
import (
"net/http"
"github.com/go-chi/cors"
)
// CORS returns a configured CORS middleware
func CORS() func(http.Handler) http.Handler {
return cors.Handler(cors.Options{
AllowedOrigins: []string{"http://localhost:*", "https://localhost:*"},
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type"},
ExposedHeaders: []string{"Link"},
AllowCredentials: true,
MaxAge: 300, // 5 minutes
})
}