diff --git a/devenv.nix b/devenv.nix index fd2fb07..fff5dff 100644 --- a/devenv.nix +++ b/devenv.nix @@ -26,14 +26,23 @@ enable = true; dataDir = "${config.env.DEVENV_STATE}/caddy"; config = '' - { - debug - } - :8080 { - root * ${config.env.DEVENV_ROOT}/.outputs/static - file_server - reverse_proxy /api/v1/* http://127.0.0.1:8000 - } + :8080 { + handle /api/* { + reverse_proxy 127.0.0.1:8000 + } + + handle { + root * ${config.env.DEVENV_ROOT}/.outputs/static + + encode zstd gzip + + @assets path /assets/* + header @assets Cache-Control "public, max-age=31536000, immutable" + + try_files {path} /index.html + file_server + } + } ''; }; diff --git a/service/auth/magic.go b/service/auth/magic.go index 8292fa1..5e12b5d 100644 --- a/service/auth/magic.go +++ b/service/auth/magic.go @@ -2,7 +2,6 @@ package auth import ( "net/http" - "net/url" "nixcn-cms/data" "nixcn-cms/internal/crypto/jwt" "nixcn-cms/pkgs/email" @@ -42,12 +41,7 @@ func RequestMagicLink(c *gin.Context) { return } - link, err := url.JoinPath(viper.GetString("server.external_url"), "/login?ticket="+token) - if err != nil { - log.Error("Magic link join failed!") - c.JSON(500, gin.H{"status": "magic link join failed"}) - return - } + link := viper.GetString("server.external_url") + "/login?ticket=" + token // Send email using resend resend, err := email.NewResendClient() @@ -58,8 +52,8 @@ func RequestMagicLink(c *gin.Context) { } resend.Send( req.Email, - "NixCN CSM Email Verify", - "Click the link below to verify your email. This link will expire in 10 minutes.\n"+link, + "NixCN CMS Email Verify", + "
Click the link below to verify your email. This link will expire in 10 minutes.
"+link+"", ) c.JSON(200, gin.H{"status": "magic link sent"})