修复 HTTP 请求
This commit is contained in:
parent
58f7a4a7ad
commit
0fa6d1e2a6
@ -37,7 +37,8 @@ private function fixPath(Request $request, Module $module, $prefix): string
|
|||||||
{
|
{
|
||||||
$path = substr($request->path(), strlen("/$prefix/modules/$module->id"));
|
$path = substr($request->path(), strlen("/$prefix/modules/$module->id"));
|
||||||
|
|
||||||
return preg_replace('/[^a-zA-Z0-9\/]/', '', $path);
|
// 去除 非法字符
|
||||||
|
return preg_replace('/[^a-zA-Z0-9\/\-]/', '', $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function exportCall(Request $request, Module $module): Response|JsonResponse
|
public function exportCall(Request $request, Module $module): Response|JsonResponse
|
||||||
|
@ -117,18 +117,20 @@ public function baseRequest($method, $path, $requests = []): array
|
|||||||
{
|
{
|
||||||
$user = auth('sanctum')->user();
|
$user = auth('sanctum')->user();
|
||||||
|
|
||||||
|
$http = $this->http();
|
||||||
if ($user) {
|
if ($user) {
|
||||||
$this->http()->withHeaders([
|
$http = $http->withHeaders([
|
||||||
'X-User-Id' => $user->id,
|
'X-User-Id' => $user->id,
|
||||||
]);
|
]);
|
||||||
$requests['user_id'] = $user->id;
|
|
||||||
if ($method == 'post') {
|
// $requests['user_id'] = $user->id;
|
||||||
// add user to requests
|
// if ($method == 'post') {
|
||||||
$requests['user'] = $user;
|
// // add user to requests
|
||||||
}
|
// $requests['user'] = $user;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $this->http()->{$method}($path, $requests);
|
$response = $http->{$method}($path, $requests);
|
||||||
|
|
||||||
return $this->getResponse($response);
|
return $this->getResponse($response);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user