Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

pmartelletti's avatar

Upgrading to Laravel 5.4 is givin 401 API responses

Not sure what's is happening. I'm calling my API from inside my app (vue components), and it used to work perfectly before upgrading from 5.3. I've checked the requests and they have the spark_token cookie, so it should be issuing the token for authentication.

I've also added new middlewares, but still not working. Did anyone had this problem as well? Any ideas on what could be wrong? Cheers,

0 likes
3 replies
beckenrode's avatar
Level 1

This is due to the expires_at column being cast as "date" instead of "datetime" in spark/src/Token.php. The "date" casting calls the startOfDay method which then sets the time to 00:00:00 resulting in the token being expired.

A fix is in the repo but doesn't appear coming down from a spark:update yet.

Until it does you can simply change 'last_used_at' and 'expires_at' from 'date' to 'datetime' in $casts of the spark/src/Token.php file.

Please or to participate in this conversation.