小编Uma*_*hid的帖子

自定义 Shopware6 路线给出“405 Method Not allowed”

我创建了一个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中创建了一个这样的插件,并且GETPOST请求已经可以正常工作,无需执行任何特殊操作。

在我的情况下,如何在Shopware6上发出ALLOW POST请求?

谢谢 !

php post plugins controller shopware

3
推荐指数
1
解决办法
965
查看次数

标签 统计

controller ×1

php ×1

plugins ×1

post ×1

shopware ×1