headers method

  1. @override
Map headers(
  1. SocketConnect connect, [
  2. Map? headers
])
override

Returns headers for a response.

Implementation

@override
Map headers(SocketConnect connect, [Map? headers]) {
  headers = headers ?? {};
  var req = connect.request;
  if (req.headers.value('origin') != null) {
    headers['Access-Control-Allow-Credentials'] = 'true';
    headers['Access-Control-Allow-Origin'] = req.headers.value('origin');
  } else {
    headers['Access-Control-Allow-Origin'] = '*';
  }
  return super.headers(connect, headers);
}