Всякий раз, когда я пытаюсь сделать AJAX-вызов с изображением base64 в теле, это выдает ошибку как:

Метод GET не поддерживается для этого маршрута. Поддерживаемые методы: POST.

Вот мой вызов ajax:

async function addToCart() { document.getElementById('preloader').style.display = 'block'; document.getElementById('addToCartButton').style.display = 'none'; // Get base64URL var image = ""; var full_image = ""; if (document.getElementById("category_id").value == 'customize back cover') { //console.log("652") await html2canvas(document.getElementById("html-content-holder")).then(function (canvas) { document.body.appendChild(canvas); var base64URL = canvas.toDataURL('image/jpeg').replace('image/jpeg', 'image/octet-stream'); full_image = base64URL; image = document.getElementById('selectedImage').src; }); } $.ajax({ type: "POST", url: "http://emlt.thebakeologyindia.com/add_to_cart", // You add the id of the post and the update datetime to the url as well data: { _token: document.getElementById('token').value, user_id: document.getElementById('user_id').value, product_id: document.getElementById('product').value, quantity: document.getElementById('quantity').value, image: image, full_image: full_image }, success: function (response) { // If not false, update the post //console.log(response); swal({ title: response.data.status, text: response.data.message, icon: response.data.status, }); if(response.data.status == "error") { document.getElementById('addToCartButton').style.display = 'block'; document.getElementById('preloader').style.display = 'none'; } else { document.getElementById('itemInCartLink').style.display = 'block'; document.getElementById('addToCartButton').style.display = 'none'; document.getElementById('preloader').style.display = 'none'; } }, error: function (error) { document.getElementById('addToCartButton').style.display = 'block'; document.getElementById('preloader').style.display = 'none'; swal({ title: "Error", text: error.message, icon: "error", }); } }); } 

Вот пример данных формы:

 _token: RHJrQ4wX6XbXqi0wOx8sMiFHCuXVI2HclGB3rDco, user_id: 1, product_id: 1, quantity: 1, image: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAu8AAAH0CAYAAACNesOUAAAgAElEQVR4XoS9iZLjWnIsGMRCAlxy.........., full_image: data:image/octet-stream;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBg.........., 

Если я удаляю изображения, то все работает нормально. И это также отлично работает в localhost. Эта проблема возникает только на сервере. Вот ссылка на сайт: http://emlt.thebakeologyindia.com/details/1 . Вы можете добавить любой другой продукт, он будет работать нормально, но когда вы попытаетесь добавить персонализированные продукты задней обложки, эта проблема возникает, потому что тогда только я отправляю изображения. Я не могу понять, в чем проблема.

Вот полный журнал ошибок:

 { "message": "The GET method is not supported for this route. Supported methods: POST.", "exception": "Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException", "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php", "line": 256, "trace": [ { "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php", "line": 242, "function": "methodNotAllowed", "class": "Illuminate\Routing\RouteCollection", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php", "line": 176, "function": "getRouteForMethods", "class": "Illuminate\Routing\RouteCollection", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 634, "function": "match", "class": "Illuminate\Routing\RouteCollection", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 623, "function": "findRoute", "class": "Illuminate\Routing\Router", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 612, "function": "dispatchToRoute", "class": "Illuminate\Routing\Router", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 176, "function": "dispatch", "class": "Illuminate\Routing\Router", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 30, "function": "Illuminate\Foundation\Http\{closure}", "class": "Illuminate\Foundation\Http\Kernel", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php", "line": 21, "function": "Illuminate\Routing\{closure}", "class": "Illuminate\Routing\Pipeline", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 163, "function": "handle", "class": "Illuminate\Foundation\Http\Middleware\TransformsRequest", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php", "line": 21, "function": "Illuminate\Routing\{closure}", "class": "Illuminate\Routing\Pipeline", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 163, "function": "handle", "class": "Illuminate\Foundation\Http\Middleware\TransformsRequest", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php", "line": 27, "function": "Illuminate\Routing\{closure}", "class": "Illuminate\Routing\Pipeline", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 163, "function": "handle", "class": "Illuminate\Foundation\Http\Middleware\ValidatePostSize", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php", "line": 62, "function": "Illuminate\Routing\{closure}", "class": "Illuminate\Routing\Pipeline", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 163, "function": "handle", "class": "Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/MobileCoverEcom/vendor/fideloper/proxy/src/TrustProxies.php", "line": 57, "function": "Illuminate\Routing\{closure}", "class": "Illuminate\Routing\Pipeline", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 163, "function": "handle", "class": "Fideloper\Proxy\TrustProxies", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "function": "Illuminate\Pipeline\{closure}", "class": "Illuminate\Pipeline\Pipeline", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 104, "function": "Illuminate\Routing\{closure}", "class": "Illuminate\Routing\Pipeline", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 151, "function": "then", "class": "Illuminate\Pipeline\Pipeline", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/MobileCoverEcom/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 116, "function": "sendRequestThroughRouter", "class": "Illuminate\Foundation\Http\Kernel", "type": "-{amp}gt;" }, { "file": "/home/thebvcgn/emlt.site/index.php", "line": 55, "function": "handle", "class": "Illuminate\Foundation\Http\Kernel", "type": "-{amp}gt;" } ] } 

Ошибка указывает на проблему с маршрутом. Это указывает на то, что вы настроили маршрут для работы с глаголами get и head, но используете post в вызове ajax.

Пожалуйста, запустите: php artisan route:list чтобы проверить, загружен ли маршрут, который вы используете в вызове ajax.

Ваш маршрут указывает метод POST .

Но вы попали в метод с помощью метода GET .

Либо исправьте вызов метода в POST, либо заставьте маршрут принимать и GET, и POST

 Route::match(['get', 'post'], '/action', 'ExampleController@action');