mirror of
https://github.com/bestnite/sub2clash.git
synced 2025-10-26 17:14:24 +00:00
fix URL construction in GetRawConfHandler
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -168,7 +169,19 @@ func GetRawConfHandler(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response, err := http.Get("http://" + strings.TrimSuffix(config.GlobalConfig.Address, "/") + "/" + shortLink.Url)
|
scheme := "http"
|
||||||
|
if c.Request.TLS != nil {
|
||||||
|
scheme = "https"
|
||||||
|
}
|
||||||
|
host := c.Request.Host
|
||||||
|
targetPath := strings.TrimPrefix(shortLink.Url, "/")
|
||||||
|
requestURL := fmt.Sprintf("%s://%s/%s", scheme, host, targetPath)
|
||||||
|
|
||||||
|
client := &http.Client{
|
||||||
|
Timeout: 30 * time.Second, // 30秒超时
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := client.Get(requestURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
respondWithError(c, http.StatusInternalServerError, "请求错误: "+err.Error())
|
respondWithError(c, http.StatusInternalServerError, "请求错误: "+err.Error())
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user