getOrigin static method

String getOrigin(
  1. APIRequest request
)

Implementation

static String getOrigin(APIRequest request) {
  var origin = request.headers['origin'];
  if (origin != null) return origin;

  var host = request.headers[HttpHeaders.hostHeader];
  if (host != null) {
    var scheme = request.requestedUri.scheme;

    origin = "$scheme://$host/";
    return origin;
  }

  origin = "http://localhost/";
  return origin;
}