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;
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
}
}
'';
};

View File

@@ -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",
"<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"})