Comments (6)
Ugh apparently I either had an idiot moment or just missed a step, the middleware line was missing. All better now :)
from laravel-caffeine.
I was wondering if this might happen. I wonder if the session is not getting refreshed in your instance. (All my routes are hitting the Session middleware, which is critical. If the route doesn't hit that, then that's the issue.)
Can you post your kernel.php
and routes.php
here for me, and let me know which routes your AJAX is hitting?
from laravel-caffeine.
Sure.
My Kernal.php
file looks like:
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array
*/
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\GeneaLabs\LaravelCaffeine\Http\Middleware\LaravelCaffeineDripMiddleware::class
];
/**
* The application's route middleware groups.
*
* @var array
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class
],
'home' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class
],
'api' => [
'throttle:60,1'
]
];
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'auth.organisation' => \App\Http\Middleware\OrganisationAccessOnly::class,
'auth.interim' => \App\Http\Middleware\InterimAccessOnly::class
];
}
and my routes.php
file is:
<?php
Route::group(['middleware' => ['web']], function () {
// This is the current route the app is on.
Route::get('/jobs/{slug}', [
'as' => 'viewjob',
'middleware' => 'auth',
'uses' => 'JobController@show'
]);
// This is the route that is hit via the a post request.
Route::post('/shortlist/add/{bidId}', [
'as' => 'addtoshortlist',
'middleware' => 'auth.organisation',
'uses' => 'ShortlistController@store'
]);
}
and with vue.js I'm making a call like this:
/*
* Add a bid to a shortlist.
*/
shortlistBid: function(bidId) {
var self = this;
this.shortlistingBid = bidId;
this.$http.post('/shortlist/add/' + bidId)
.success(function() {
this.getBids();
this.shortlistingBid = false;
});
},
The issue must be with the refreshing of the tokens in my view. Somehow it's not taking place.
from laravel-caffeine.
Laravel 5.2 project, same overall issue here. I have Caffeine installed as instructed in the docs, it does appear to be working at all anymore. Receiving TokenMismatchException errors for the login form and Ajax pages throughout the project. Here is my CSRF token meta:
<meta name="csrf-token" id="csrf-token" content="{{ csrf_token() }}">
I am also using VueJS, same settings as olimorris. Composer line:
"genealabs/laravel-caffeine": "^0.3.8",
from laravel-caffeine.
@mikebronner I owe you an apology! I was using this on my dev machine and Laravel DebugBar
always seems to these errors:
XMLHttpRequest cannot load http://myproject.dev/_debugbar/open?op=get&id=7993e14d3edd1828e4b3d1be9e39939b. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access
Now when I use BarryVDH's Cors
package, these errors stop and Laravel Caffeine works.
@opheliadesign can you see if you're having the exact same issues then I think this issue can be closed!
from laravel-caffeine.
Ah, that's good to know! I will add a note to the README.
from laravel-caffeine.
Related Issues (20)
- Issue in production when changing the drip endpoint url default HOT 5
- Can't install in Laravel 7.0.1 HOT 1
- Vue.js @click events not working after installing 7.0 HOT 8
- Issue parsing inline javascript HOT 9
- What's wrong with exposing the CSRF token? HOT 1
- Caffeine javascript is behind closing body-tag HOT 4
- Dependency incompatibility issues for laravel 5 (and suspected 6) HOT 1
- Add Laravel 8.x support
- Move to GitHub Actions for CI. HOT 1
- Failed Installation HOT 3
- Ath_j22 HOT 1
- Composer require error HOT 2
- Issue with caffeine not loading other packages correctly when it refreshes. HOT 1
- Should fix when the device is in sleep mode HOT 1
- The included script is added in a place where it affects my site layout HOT 2
- Laravel 9 support HOT 7
- Deprecation warning using with PHP 8.1 HOT 3
- Laravel 10 support HOT 5
- Not Working in Production environment HOT 4
- XSRF Header Support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-caffeine.