Fix caddy api proxy

Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
2025-12-25 13:14:30 +08:00
parent 942767aed3
commit 9c7cfb3da6
2 changed files with 20 additions and 17 deletions

View File

@@ -26,14 +26,23 @@
enable = true; enable = true;
dataDir = "${config.env.DEVENV_STATE}/caddy"; dataDir = "${config.env.DEVENV_STATE}/caddy";
config = '' config = ''
{ :8080 {
debug handle /api/* {
} reverse_proxy 127.0.0.1:8000
:8080 { }
root * ${config.env.DEVENV_ROOT}/.outputs/static
file_server handle {
reverse_proxy /api/v1/* http://127.0.0.1:8000 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
}
}
''; '';
}; };

View File

@@ -2,7 +2,6 @@ package auth
import ( import (
"net/http" "net/http"
"net/url"
"nixcn-cms/data" "nixcn-cms/data"
"nixcn-cms/internal/crypto/jwt" "nixcn-cms/internal/crypto/jwt"
"nixcn-cms/pkgs/email" "nixcn-cms/pkgs/email"
@@ -42,12 +41,7 @@ func RequestMagicLink(c *gin.Context) {
return return
} }
link, err := url.JoinPath(viper.GetString("server.external_url"), "/login?ticket="+token) link := 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
}
// Send email using resend // Send email using resend
resend, err := email.NewResendClient() resend, err := email.NewResendClient()
@@ -58,8 +52,8 @@ func RequestMagicLink(c *gin.Context) {
} }
resend.Send( resend.Send(
req.Email, req.Email,
"NixCN CSM Email Verify", "NixCN CMS Email Verify",
"Click the link below to verify your email. This link will expire in 10 minutes.\n"+link, "<p>Click the link below to verify your email. This link will expire in 10 minutes.</p><a href="+link+">"+link+"</a>",
) )
c.JSON(200, gin.H{"status": "magic link sent"}) c.JSON(200, gin.H{"status": "magic link sent"})