Frage

I'm making web app using Laravel and AngularJS. To prevent CSRF, I added following script to index.php file.

<script>
angular.module("contactApp").constant("CSRF_TOKEN", '<?php echo csrf_token(); ?>');
</script>

But it shows the following Fatal error.

"Call to undefined function csrf_token()"

In Laravel setting, I changed the View Storage Paths in view.php to public_html folder. It seems it makes the error. How I can solve this problem with using an alternative View Storage Paths?

War es hilfreich?

Lösung

Probably you have a wrong value in you're view path?

// view.php
'paths' => array(__DIR__.'/../../public'),

Andere Tipps

To get a CSRF token in Laravel the code is:

<?php echo Form::token(); ?>

or if your using Blade templates:

{{ Form::token() }}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top