def token_origin(self):
        """Compute the origin used by build tokens

        For build tokens we check the Origin and then the Host header to
        compute the "origin" of a build token.
        """
        origin_or_host = self.request.headers.get("origin", None)
        if origin_or_host is not None:
            # the origin header includes the scheme, which the host header
            # doesn't so we normalize Origin to the format of Host
            origin_or_host = urllib.parse.urlparse(origin_or_host).netloc
        else:
            origin_or_host = self.request.headers.get("host", "")

        return origin_or_host
Compute the origin used by build tokens

        For build tokens we check the Origin and then the Host header to
        compute the "origin" of a build token.
        
binderhub/base.py