-rw-r--r-- | ui-shared.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/ui-shared.c b/ui-shared.c index 4818e70..c23bc75 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -29,32 +29,37 @@ static char *http_date(time_t t) void cgit_print_error(char *msg) { html("<div class='error'>"); html_txt(msg); html("</div>\n"); } char *cgit_hosturl() { char *host, *port; - host = getenv("SERVER_NAME"); - if (!host) - return NULL; - port = getenv("SERVER_PORT"); - if (port && atoi(port) != 80) - host = xstrdup(fmt("%s:%d", host, atoi(port))); - else + host = getenv("HTTP_HOST"); + if (host) { host = xstrdup(host); + } else { + host = getenv("SERVER_NAME"); + if (!host) + return NULL; + port = getenv("SERVER_PORT"); + if (port && atoi(port) != 80) + host = xstrdup(fmt("%s:%d", host, atoi(port))); + else + host = xstrdup(host); + } return host; } char *cgit_rooturl() { if (ctx.cfg.virtual_root) return fmt("%s/", ctx.cfg.virtual_root); else return ctx.cfg.script_name; } char *cgit_repourl(const char *reponame) |