chore: configure cors and simplify template

This commit is contained in:
log101 2024-05-30 13:53:20 +03:00
parent a376800eeb
commit 416a93d6a0
2 changed files with 8 additions and 2 deletions

View File

@ -93,7 +93,13 @@ func main() {
// CORS configuration // CORS configuration
corsConfig := cors.DefaultConfig() 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"} corsConfig.AllowHeaders = []string{"hx-current-url", "hx-request"}
r.Use(cors.New(corsConfig)) r.Use(cors.New(corsConfig))

View File

@ -1,4 +1,4 @@
<form hx-post="http://localhost:8000/forms/emoji/post" hx-swap="outerHTML"> <form hx-post="/blog/api/forms/emoji/post" hx-swap="outerHTML">
<input type="hidden" name="postId" value="{{.postId}}"> <input type="hidden" name="postId" value="{{.postId}}">
<div class="emoji-buttons-container"> <div class="emoji-buttons-container">
{{ range .results }} {{ range .results }}