我创建了一个shopware6插件,其中包含一个前端自定义路由,该路由应该能够接收来自 ExactOnline 的 POST 请求。
但是当我用 Postman 进行一些测试时,我收到“ 405 Method Not allowed ”。这是我的控制器:
<?php
namespace Emakers\TransmissionPlugin\Controller;
//use Emakers\TransmissionPlugin\Controller\Frontend\Services\ExactRequirements;
use Shopware\Core\Framework\Routing\Annotation\RouteScope;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Shopware\Storefront\Controller\StorefrontController;
use Symfony\Component\Routing\Annotation\Route;
/**
* @RouteScope(scopes={"storefront"})
*/
class AccountsController extends StorefrontController
{
/**
* @Route("/accounts", name="frontend.accounts", options={"seo"="false"}, methods={"POST"})
*/
public function accounts()
{
die('ok boy');
$file = 'custom/plugins/TransmissionPlugin/Resources/webhooks/accountWebhook.txt';
}
}
Run Code Online (Sandbox Code Playgroud)
当我用methods={"GET"}替换methods = {"POST"}时,相同的测试请求返回“ok boy”,这是正常的。
我已经在Shopware5中创建了一个这样的插件,并且GET和POST请求已经可以正常工作,无需执行任何特殊操作。
在我的情况下,如何在Shopware6上发出ALLOW POST请求?
谢谢 !