我得到了这个错误NotFoundHttpException引发了一个消息说“提供了错误的主机名”,即使它在尝试使用Dio包从Flutter保存数据时在本地运行,但当使用Postman时,它工作正常,没有引发错误。一直在变通,但没有解决这个问题的办法。知道为什么会出现这个错误吗?
验证码:
public function store(StoreSaleRequest $request)
{
$waybillNumber = GenerateUniqueId::create('sales', 'FMC', $request->customer_type === 'regular' ? 'R' : 'D', 7, true);
$customer = $this->createOrUpdateCustomer($request);
$sale = Sale::create([
'customer_id' => $customer->id,
'waybill_number' => $waybillNumber,
'amount_paid' => $request->amount_paid,
'cod' => $request->cod,
'date' => $request->date ?? now(),
'total_price' => $request->total_price,
'delivery_fee' => $request->delivery_fee,
'subtotal' => $request->subtotal,
'transaction_id' => $request->transaction_id,
'customer_type' => $request->customer_type,
'discount' => $request->discount,
'payment_type' => $request->payment_type,
]);
$sale->salesItems()->createMany($request->items);
$this->updateStock($customer->id, $request->items);
if ($sale->customer) {
SmsJob::dispatch(
config('services.default_sms'),
$sale->customer->phone,
"message",
)
->delay(now()->addSeconds(20));
}
$sale->load('salesItems');
return response()->json([
'status' => true,
'message' => 'Sale saved successfully',
]);
}
错误:
message: Bad hostname provided., exception: Symfony\Component\HttpKernel\Exception\NotFoundHttpException, file: /Users/okmans/Projects/FM Cosmetics/app/erp project/sports/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php, line: 414, trace: [{file: /Users/okmans/Projects/FM Cosmetics/app/erp project/sports/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php, line: 384, function: prepareException, class: Illuminate\Foundation\Exceptions\Handler, type: ->}, {file: /Users/okmans/Projects/FM Cosmetics/app/erp project/sports/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php, line: 51, function: render, class: Illuminate\Foundation\Exceptions\Handler, type: ->}, {file: /Users/okmans/Projects/FM Cosmetics/app/erp project/sports/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php, line: 185, function: handleException, class: Illuminate\Routing\Pipeline, type: ->}, {file: /Users/okmans/Projects/FM Cosmetics/app/erp project/sports/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php, line: 39, function: Illuminate\Pipeline\{closure}, class: Illuminate\Pipeline\Pipeline, type: ->}, {file: /Users/okmans/Projects/FM Cosmetics/app/erp project/sports/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php, line: 180, function: handle, class: Illuminate\Http\Middleware\TrustProxies, type: ->}, {file: /Users/okmans/Projects/FM Cosmetics/app/erp project/sports/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php, line: 116, function: Illuminate\Pipeline\{closure}, class: Illuminate\Pipeline\Pipeline, type: ->}, {file: /Users/okmans/Projects/FM Cosmetics/app/erp project/sports/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php, line: 175, function: then, class: Illuminate\Pipeline\Pipeline, type: ->}, {file: /Users/okmans/Projects/FM Cosmetics/app/erp project/sports/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php, line: 144, function: sendRequestThroughRouter, class: Illuminate\Foundation\Http\Kernel, type: ->}, {file: /Users/okmans/Projects/FM Cosmetics/app/erp project/sports/public/index.php, line: 51, function: handle, class: Illuminate\Foundation\Http\Kernel, type: ->}, {file: /Users/okmans/Projects/FM Cosmetics/app/erp project/sports/vendor/laravel/framework/src/Illuminate/Foundation/resources/server.php, line: 16, function: require_once}]}
1条答案
按热度按时间sulc1iza1#
我通过显式添加方法- POST来修复它,如下所示:
“_method”:“POST”发送前。我不知道它是怎么工作的。