mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-11 23:04:29 +00:00
Always set Access-Control-Allow-Origin on response
Error responses were not having this set, which obscured the true error from the client.
This commit is contained in:
parent
94521b73bb
commit
18f97b6ec1
@ -79,12 +79,16 @@ static id s_executor;
|
|||||||
NSError *error;
|
NSError *error;
|
||||||
NSData *data = [(GCDWebServerDataRequest *)request data];
|
NSData *data = [(GCDWebServerDataRequest *)request data];
|
||||||
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
|
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
|
||||||
if (error) {
|
GCDWebServerResponse *response;
|
||||||
NSLog(@"%@", error);
|
|
||||||
return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_UnprocessableEntity underlyingError:error message:@"Invalid RPC request"];
|
if (error || ![json isKindOfClass:[NSDictionary class]]) {
|
||||||
|
NSLog(@"Invalid RPC request - %@", error ?: json);
|
||||||
|
response = [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_UnprocessableEntity underlyingError:error message:@"Invalid RPC request"];
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
GCDWebServerDataResponse *response = [GCDWebServerDataResponse responseWithJSONObject:[rpcServer performRequest:request.path args:json]];
|
response = [GCDWebServerDataResponse responseWithJSONObject:[rpcServer performRequest:request.path args:json]];
|
||||||
|
}
|
||||||
|
|
||||||
[response setValue:@"http://localhost:8081" forAdditionalHeader:@"Access-Control-Allow-Origin"];
|
[response setValue:@"http://localhost:8081" forAdditionalHeader:@"Access-Control-Allow-Origin"];
|
||||||
return response;
|
return response;
|
||||||
}];
|
}];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user