Fix proxy
This commit is contained in:
parent
88a57252ed
commit
061b4a84c1
|
@ -20,13 +20,13 @@ class Proxy
|
||||||
|
|
||||||
protected function get(string $url): ?array
|
protected function get(string $url): ?array
|
||||||
{
|
{
|
||||||
$response = Http::acceptJson()->get($this->url($url));
|
$response = Http::header('Accept', 'application/json')->get($this->url($url));
|
||||||
|
|
||||||
if (!$response->ok()) {
|
if (!$response->ok) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response->json();
|
return json_decode($response->body, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function submit(string $url): JsonResponse
|
public function submit(string $url): JsonResponse
|
||||||
|
@ -36,9 +36,12 @@ class Proxy
|
||||||
'Authorization' => 'Bearer ' . request()->header('X-Adrema-Token'),
|
'Authorization' => 'Bearer ' . request()->header('X-Adrema-Token'),
|
||||||
]
|
]
|
||||||
: [];
|
: [];
|
||||||
$response = Http::acceptJson()->withHeaders($headers)->post($this->url($url), request()->input());
|
$response = Http::make($this->url($url), 'POST')
|
||||||
|
->setOption(CURLOPT_POSTFIELDS, json_encode(request()->input()))
|
||||||
|
->header([...$headers, 'Accept' => 'application/json', 'Content-Type' => 'application/json'])
|
||||||
|
->send();
|
||||||
|
|
||||||
return response()->json($response->json(), $response->status());
|
return response()->json(json_decode($response->body, true), $response->code);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function url(string $internal): string
|
private function url(string $internal): string
|
||||||
|
|
Loading…
Reference in New Issue