From 416a93d6a0425936f643a51fd9684ae1ef4be007 Mon Sep 17 00:00:00 2001 From: log101 Date: Thu, 30 May 2024 13:53:20 +0300 Subject: [PATCH] chore: configure cors and simplify template --- main.go | 8 +++++++- templates/emoji_form.tmpl | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index a8ba92f..30b91d4 100644 --- a/main.go +++ b/main.go @@ -93,7 +93,13 @@ func main() { // CORS configuration corsConfig := cors.DefaultConfig() - corsConfig.AllowOrigins = []string{"*"} + corsConfig.AllowOrigins = []string{"https://log101.dev"} + + ginMode := gin.Mode() + if ginMode == gin.DebugMode { + corsConfig.AllowOrigins = append(corsConfig.AllowOrigins, "http://localhost:4321") + } + corsConfig.AllowHeaders = []string{"hx-current-url", "hx-request"} r.Use(cors.New(corsConfig)) diff --git a/templates/emoji_form.tmpl b/templates/emoji_form.tmpl index b469e50..ef45f51 100644 --- a/templates/emoji_form.tmpl +++ b/templates/emoji_form.tmpl @@ -1,4 +1,4 @@ -
+
{{ range .results }}