Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/pkg/web/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,9 @@ func (c *Context) RemoveCookie(name string) {

// BaseURL returns base URL
func (c *Context) BaseURL() string {
if env.IsSingleHostMode() {
return env.Config.BaseURL
}
return c.Request.BaseURL()
}

Expand Down
23 changes: 23 additions & 0 deletions app/pkg/web/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func TestContextID(t *testing.T) {

func TestBaseURL(t *testing.T) {
RegisterT(t)
env.Config.HostMode = "multi"

ctx := newGetContext("http://demo.test.fider.io:3000", nil)

Expand All @@ -59,6 +60,7 @@ func TestBaseURL(t *testing.T) {

func TestBaseURL_HTTPS(t *testing.T) {
RegisterT(t)
env.Config.HostMode = "multi"

ctx := newGetContext("https://demo.test.fider.io:3000", nil)

Expand All @@ -67,6 +69,7 @@ func TestBaseURL_HTTPS(t *testing.T) {

func TestBaseURL_HTTPS_Proxy(t *testing.T) {
RegisterT(t)
env.Config.HostMode = "multi"

ctx := newGetContext("http://demo.test.fider.io:3000", map[string]string{
"X-Forwarded-Proto": "https",
Expand All @@ -75,6 +78,26 @@ func TestBaseURL_HTTPS_Proxy(t *testing.T) {
Expect(ctx.BaseURL()).Equals("https://demo.test.fider.io:3000")
}

func TestBaseURL_SingleHostMode(t *testing.T) {
RegisterT(t)
env.Config.HostMode = "single"
env.Config.BaseURL = "https://example.com"

ctx := newGetContext("http://demo.test.fider.io:3000", nil)

Expect(ctx.BaseURL()).Equals("https://example.com")
}

func TestBaseURL_SingleHostMode_WithPath(t *testing.T) {
RegisterT(t)
env.Config.HostMode = "single"
env.Config.BaseURL = "https://example.com/feedback"

ctx := newGetContext("http://demo.test.fider.io:3000", nil)

Expect(ctx.BaseURL()).Equals("https://example.com/feedback")
}

func TestCurrentURL(t *testing.T) {
RegisterT(t)

Expand Down