LoginSignup
1
1

More than 3 years have passed since last update.

laravel 外部からのPOSTを許可

Posted at

suicreditのクレジット決済を導入したい。

決済完了後、
先方から当サイトへの戻りとしてPOST送信でリンク移動する。

つまり、普通のリンク移動でないので、POST送信を許可しないと以下のエラーが出る。


Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException
No message

同一サイト内のPOSTならフォーム内に
{{ csrf_field() }}
と書くだけなのだが・・・。

ということで、外部から指定URLへのPOST送信を許可する方法。

指定URLへ、外部からのPOST送信を許可

Http/Middleware/VerifyCsrfToken.php

    protected $except = [
        '/mypage',
        //
    ];

vue.js で get でも post でも全て受け付けるように

web.php

Route::match(['get', 'post'] ,'/{app}', function () {
    //本番になったら削除する
    \File::cleanDirectory(storage_path()."/framework/views/");
    return view('vue');
})->where('app', '.*');

これで外部からのPOSTも受けることができる。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1