🐛 Fix aliasing issue
This commit is contained in:
parent
5dbe1cf80d
commit
38b52aec2f
@ -25,8 +25,9 @@ func listExistsService(c *fiber.Ctx) error {
|
||||
|
||||
func forwardServiceRequest(c *fiber.Ctx) error {
|
||||
serviceType := c.Params("service")
|
||||
ogKeyword := serviceType
|
||||
|
||||
aliasingMap := viper.GetStringMapString("services.alias")
|
||||
aliasingMap := viper.GetStringMapString("services.aliases")
|
||||
if val, ok := aliasingMap[serviceType]; ok {
|
||||
serviceType = val
|
||||
}
|
||||
@ -39,11 +40,7 @@ func forwardServiceRequest(c *fiber.Ctx) error {
|
||||
|
||||
ogUrl := c.Request().URI().String()
|
||||
url := c.OriginalURL()
|
||||
prevUrl := url
|
||||
url = strings.Replace(url, "/srv/"+serviceType, "/api", 1)
|
||||
if prevUrl == url {
|
||||
url = strings.Replace(url, "/cgi/"+serviceType, "/api", 1)
|
||||
}
|
||||
url = strings.Replace(url, "/cgi/"+ogKeyword, "/api", 1)
|
||||
url = "http://" + *service.HttpAddr + url
|
||||
|
||||
log.Debug().
|
||||
|
@ -16,7 +16,6 @@ func MapAPIs(app *fiber.App) {
|
||||
}
|
||||
|
||||
app.All("/cgi/:service/*", forwardServiceRequest)
|
||||
app.All("/srv/:service/*", forwardServiceRequest)
|
||||
|
||||
api := app.Group("/api").Name("API")
|
||||
{
|
||||
|
@ -37,5 +37,5 @@ access_token_duration = 300
|
||||
refresh_token_duration = 2592000
|
||||
|
||||
[services]
|
||||
alias = { id = "auth", uc = "files", co = "interactive", im = "messagings" }
|
||||
aliases = { id = "auth", uc = "files", co = "interactive", im = "messaging" }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user