- GetOrCreateDeliveryLink/RestoreDeliveryLink 增加 requestBaseURL 参数 - buildDeliveryURL 优先级:DELIVERY_BASE_URL → 请求域名 → 路径 - 支持 X-Forwarded-Proto 与 TLS 判断 https
19 lines
545 B
Go
19 lines
545 B
Go
package handler
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// requestBaseURL 根据当前请求推导站点基础地址(如 https://skin.khhao.com)。
|
|
// 优先取配置的 DELIVERY_BASE_URL(服务层),为空时由请求的 scheme + Host 推导,
|
|
// 保证发货链接始终返回完整可访问的 URL。
|
|
func requestBaseURL(c *gin.Context) string {
|
|
scheme := "http"
|
|
if c.Request.TLS != nil || strings.EqualFold(c.GetHeader("X-Forwarded-Proto"), "https") {
|
|
scheme = "https"
|
|
}
|
|
return scheme + "://" + c.Request.Host
|
|
}
|