mirror of
https://github.com/YFGaia/dify-plus.git
synced 2026-06-04 10:14:00 +08:00
fix: 修正后台钉钉回调域名显示问题
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package gaia
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/gaia"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -18,8 +20,12 @@ type SystemApi struct{}
|
||||
// @Success 200 {object} response.Response{data=gaia.Tenants,msg=string} "查询成功"
|
||||
// @Router /gaia/system/dingtalk [get]
|
||||
func (systemApi *SystemApi) GetDingTalk(c *gin.Context) {
|
||||
var host string
|
||||
var config = make(map[string]interface{})
|
||||
config["host"] = c.Request.Header.Get("Referer")
|
||||
if host, _ = global.GVA_Dify_REDIS.Get(context.Background(), "api_host").Result(); len(host) == 0 {
|
||||
host = global.GVA_CONFIG.Gaia.Url
|
||||
}
|
||||
config["host"] = host
|
||||
config["config"] = systemIntegratedService.GetIntegratedConfig(gaia.SystemIntegrationDingTalk)
|
||||
response.OkWithData(config, c)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package gaia
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
@@ -32,7 +33,11 @@ func (s *SystemOAuth2Api) GetOAuth2Config(c *gin.Context) {
|
||||
configMap.Status = integrated.Status
|
||||
configMap.Classify = integrated.Classify
|
||||
configMap.AppSecret = integrated.AppSecret
|
||||
config["host"] = c.Request.Header.Get("Referer")
|
||||
var host string
|
||||
if host, _ = global.GVA_Dify_REDIS.Get(context.Background(), "api_host").Result(); len(host) == 0 {
|
||||
host = global.GVA_CONFIG.Gaia.Url
|
||||
}
|
||||
config["host"] = host
|
||||
config["config"] = configMap
|
||||
response.OkWithData(config, c)
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@ import json
|
||||
from enum import StrEnum
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
import re # extend: oauth2
|
||||
from configs import dify_config
|
||||
from extensions.ext_database import db
|
||||
from flask import request # extend: oauth2
|
||||
from extensions.ext_redis import redis_client # extend: oauth2
|
||||
from services.billing_service import BillingService
|
||||
from services.enterprise.enterprise_service import EnterpriseService
|
||||
from models.system_extend import SystemIntegrationExtend, SystemIntegrationClassify # Extend DingTalk third-party login
|
||||
@@ -115,6 +117,13 @@ class FeatureService:
|
||||
@classmethod
|
||||
def get_system_features(cls) -> SystemFeatureModel:
|
||||
system_features = SystemFeatureModel()
|
||||
# extend start: oauth2
|
||||
api_host = request.host_url
|
||||
# 通过nginx代理转发会导致 request.host_url 获取的是内网ip,这个时候使用.env的配置
|
||||
if bool(re.search(r'^(?:[0-9]{1,3}\.){3}[0-9]{1,3}', request.host_url)):
|
||||
api_host = dify_config.CONSOLE_WEB_URL
|
||||
redis_client.set("api_host", api_host)
|
||||
# extend stop: oauth2
|
||||
|
||||
cls._fulfill_system_params_from_env(system_features)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user