From ac1aace21403a4486d3094eb31d49552c56b607d Mon Sep 17 00:00:00 2001 From: ben-toogood Date: Fri, 7 Aug 2020 20:54:55 +0100 Subject: [PATCH] route the API subdomain (#1910) Co-authored-by: Asim Aslam --- api/resolver/subdomain/subdomain.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/api/resolver/subdomain/subdomain.go b/api/resolver/subdomain/subdomain.go index 086ed030..c2c381a0 100644 --- a/api/resolver/subdomain/subdomain.go +++ b/api/resolver/subdomain/subdomain.go @@ -66,6 +66,11 @@ func (r *Resolver) Domain(req *http.Request) string { // remove the domain from the host, leaving the subdomain, e.g. "staging.foo.myapp.com" => "staging.foo" subdomain := strings.TrimSuffix(host, "."+domain) + // ignore the API subdomain + if subdomain == "api" { + return "" + } + // return the reversed subdomain as the namespace, e.g. "staging.foo" => "foo-staging" comps := strings.Split(subdomain, ".") for i := len(comps)/2 - 1; i >= 0; i-- {