nothingworksinc / ticketbeast

Back to the lesson videos:
https://course.testdrivenlaravel.com/lessons
552 stars 11 forks source link

Token Mismatch Exception when testing stripe manually. #85

Closed JamesAnelay closed 6 years ago

JamesAnelay commented 6 years ago

Currently i'm finishing Lesson 60 - Moment of truth. However the javascript post to "http://local.ticketbeast.com/concerts/1/orders" is returning a 500 internal server error with the below code when doing a manual order test:

   TokenMismatchException in VerifyCsrfToken.php line 68: 
   in VerifyCsrfToken.php line 68
    at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 137
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
   .......

Did I miss something in one of the lessons relating to this? If I update VerifyCsrfToken.php to not require a Csf it works, however i'm sure thats not the "correct" way to be doing this.

 protected $except = [
        '*'
    ];

I see that in app.blade.php we specify the following,

  window.App = {
        csrfToken: '{{ csrf_token() }}',
         stripePublicKey: '{{ config('services.stripe.key') }}',
  }

I also tried passing App.csrfToken to axios.post as "_token" and that didn't do the trick. Also tried the below with no luck

window.axios.defaults.headers.common = {
    'X-CSRF-TOKEN': App.csrfToken,

Where is this App.csrfToken used anywhere?

JamesAnelay commented 6 years ago

After writing this I realised that the CSRF token was being passed, however something was wrong after than. Turned out to be file and directory permissions.