私は、トランザクションを処理するためにカスタムアーティザンコマンドを実行しようとしているlaravel APIを持っています。 apiは、マーチャントデータベースの保留中のトランザクションをチェックし、トランザクションデータベースにポストします。 は、私は次のエラーを取得する:私が使用している405メソッドが許可されていませんPOST Laravel
[GuzzleHttp\Exception\ClientException]
Client error: `POST http://paycentral.mymarket.com/transactions/bulk` resulted in a `405 Method Not Allowed` response:
{"error":{"message":"405 Method Not Allowed","status_code":405,"debug":{"line":446,"file":"\/var\/www\/vhosts\/maindomai (truncated...)
APIはapi.mymarket.comに位置しています。このようなエラーを検索すると、それがCORS関連の問題だと私は信じています。私はlaravel-corsを使用していて、ヘッダーはapi.mymarket.comとpaycentral.mymarket.comの両方のパブリックフォルダにある.htaccessにAccess Control-Allow-Origin "*"を追加しました。しかし、エラーは依然として持続しています。可能な他の回避策はありますか?現在、ホスティングサービスにはpleskを使用しています。
UPDATE:api.mymarket.com アクセス制御リクエスト・メソッド:POST アクセス制御リクエスト-ヘッダ:私は有料のサブドメイン 起源でプリフライトリクエストをやってみました
MM
それは返さ私が推測する進歩である500の内部エラー。UPDATEここはpaycentralのroutes.phpです。 cors-libraryはapp.phpに登録されています。あなたのルートはroutes.phpの中で明確に定義され、そして他のすべてが罰金であると仮定すると
<?php
$api = app('Dingo\Api\Routing\Router');
// all routes are protected by the Authenticate middleware which makes sure the client
// is authenticated as *somebody* - each resource is further protected by the authorization
// policies in the App\Api\V1\Policies files to limit the method calls by which client
// type is attempting to access the resource - these must be mapped in the AuthServiceProvider
$api->group([
'version' => 'v1',
'namespace' => 'App\Api\V1\Controllers',
'middleware' => 'auth' // use the Authenticate middleware
], function($api) {
/*
* partial CRUD resource routes
*/
$api->get('transactions/{id}', '[email protected]');
$api->post('transactions', '[email protected]');
$api->put('transactions/{id}', '[email protected]');
$api->post('transactions/bulk', '[email protected]_bulk');
$api->post('transactions/get_updates', '[email protected]_updates');
あなたは 'route.php'の経路定義について確信していますか? –
'laravel-cors'ライブラリのミドルウェアをすべてのルートまたはその特定のルートに追加しましたか?また、CORSの問題ではないかもしれません。なぜなら、飛行前にリクエストエラーが出る可能性があるからです。 –
カールリクエストをしている場合は、CORSと何も関係がありません。 CORSは、クロス・オリジン・リクエストを別のドメインとする場合にのみ使用されます。 – Tom