user2796124
user2796124

Reputation:

Laravel artisan serve on remote server

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() }}

Upvotes: 0

Views: 2312

Answers (2)

PassionInfinite
PassionInfinite

Reputation: 638

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() }}

Upvotes: 1

Sujal Patel
Sujal Patel

Reputation: 624

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

Upvotes: 0

Related Questions