0

Hi I have deployed my Laravel app on a remote server using sudo php artisan serve --host 0.0.0.0 --port 80 but when I login I get TokenMismatchException. The app is working fine in my local environment and my login form did contains {{ csrf_field() }}

2 Answers2

1

First of all, you should not use php artisan serve command in the production mode. You have to just point out the baseUrl like http://or.net/ to laravel's public/index.php file. It will bootstrap your laravel application with all the dependencies. For more details on the hosting of laravel on shared server, visit this CW answer.

And the solution to the CSRF token problem is answered by @sujalPatel. You have to add

{!! csrf_field() !!} not {{ csrf_field() }}

Graham
  • 7,431
  • 18
  • 59
  • 84
PassionInfinite
  • 640
  • 4
  • 14
  • No offense but I did mention my form contains {{ csrf_field() }} and its working on local dev environment. It just stops working on remote server. –  Jan 19 '17 at 07:38
0

Try this:

I'm assuming you added $this->middleware('auth'); inside the constructor of your controller to get the authentication working. Add the following at the top as well, under your login/register forms, if you are using {!! Form::someElement !!}:

{!! csrf_field() !!}

Or if you are using input tags inside your forms, just add this just after the tag:

<input type="hidden" name="_token" value="{{ csrf_token() }}">

TokenMismatchException in VerifyCsrfToken.php Line 67

Community
  • 1
  • 1
Sujal Patel
  • 592
  • 2
  • 5
  • 14
  • No offense but I did mention my form contains {{ csrf_field() }} and its working on local dev environment. It just stops working on remote server. –  Jan 19 '17 at 07:38