트랜잭션을 처리하기 위해 사용자 지정 숙련도 명령을 실행하려고하는 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의 public 폴더에있는 .htaccess에 대해 Access Control-Allow-Origin "*"을 설정했다. 그래도 오류가 지속됩니다. 가능한 다른 해결 방법이 있습니까? 우리는 현재 호스팅 서비스에 plesk를 사용하고 있습니다.
UPDATE : api.mymarket.com 액세스 제어 - 요청 - 방법 : POST 액세스 제어 - 요청 - 헤더 : 내가 지불 하위 도메인 원산지에서 프리 플라이트 요청을하고 시도
MM
그것은 반환 500의 내부 오류는 내가 추측하는 진보이다.업데이트 여기 paycentral에 대한 routes.php가 있습니다. cors-library는 app.php에 등록되어 있습니다.
경로가 routes.php에 잘 정의하고, 다른 모든 것이 괜찮된다고 가정 paycentral 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