Open platform to collect and prioritize feedback
fix: return absolute url for assets
goenninga3f4cb5ed0a4
diff --git a/app/pkg/web/context.go b/app/pkg/web/context.goindex d60f8e46b..e566a03f6 100644--- a/app/pkg/web/context.go+++ b/app/pkg/web/context.go@@ -550,6 +550,7 @@ func TenantBaseURL(ctx context.Context, tenant *entity.Tenant) string {}// AssetsURL return the full URL to a tenant-specific static asset+// It should always return an absolute URLfunc AssetsURL(ctx context.Context, path string, a ...any) string {request := ctx.Value(app.RequestCtxKey).(Request)path = fmt.Sprintf(path, a...)@@ -558,7 +559,7 @@ func AssetsURL(ctx context.Context, path string, a ...any) string {if env.Config.CDN.Host != "" {return request.URL.Scheme + "://" + env.Config.CDN.Host + path}- return path+ return BaseURL(ctx) + path}tenant, hasTenant := ctx.Value(app.TenantCtxKey).(*entity.Tenant)diff --git a/app/pkg/web/context_test.go b/app/pkg/web/context_test.goindex 151ec12a6..8bf097095 100644--- a/app/pkg/web/context_test.go+++ b/app/pkg/web/context_test.go@@ -128,8 +128,8 @@ func TestAssetsURL_SingleHostMode(t *testing.T) {Subdomain: "theavengers",})- Expect(web.AssetsURL(ctx, "/assets/main.js")).Equals("/assets/main.js")- Expect(web.AssetsURL(ctx, "/assets/main.css")).Equals("/assets/main.css")+ Expect(web.AssetsURL(ctx, "/assets/main.js")).Equals("https://test.fider.io:3000/assets/main.js")+ Expect(web.AssetsURL(ctx, "/assets/main.css")).Equals("https://test.fider.io:3000/assets/main.css")env.Config.CDN.Host = "fidercdn.com"Expect(web.AssetsURL(ctx, "/assets/main.js")).Equals("http://fidercdn.com/assets/main.js")