Category : laravel-sanctum

I have developed a front (react) and a back (php laravel) with the authentication system "sanctum". All is working fine on localhost. But I can’t get it to work in production in heroku. In local environment ,my .env is (extract) : SESSION_DRIVER=cookie SANCTUM_STATEFUL_DOMAINS=localhost:3000,127.0.0.1:3000,localhost:8000,127.0.0.1:8000 SESSION_DOMAIN=localhost If I have understood well, the front and back must be ..

Read more

What I did: I added token expiration to application that has login system, by changed null to 1 minute expiration in sanctum.php file: /* |————————————————————————– | Expiration Minutes |————————————————————————– | | This value controls the number of minutes until an issued token will be | considered expired. If this value is null, personal access tokens ..

Read more

As the title. I’m trying to custom model User with 2 columns as groups of primary keys. I used HasCompositePrimaryKey but still had an error: array_key_exists(): The first argument should be either a string or an integer My HasCompositePrimaryKey: namespace AppModelsTraits; use IlluminateDatabaseEloquentBuilder; trait HasCompositePrimaryKey { /** * Set the keys for a save update ..

Read more

I’m trying to authorize a private channel. I’m using Vue.js as SPA, Laravel Sanctum for auth, and Laravel for api. As the Laravel’s documentation, I wrote my channel callbacks on "channels.php" under "routes" folder. But it wasn’t working. It was saying 403 when I tried to authenticate the channel. Then I moved my channel callbacks ..

Read more

First of all, its not a duplicated because i already tried every solution given on "duplicates" and nothing worked Honestly i’m loosing my mind with that, i already tried eveything on the Internet, i keep getting CORS error when trying to get CSRF-TOKEN on localhost Laravel App: localhost:8000 Vue App: localhost:8080 I also changed sanctum ..

Read more

I’m using laravel sanctum, along with laravel fortify. I’m able to log in, but when I fetch mydomain.test/api/user i’m getting 401 (Unauthorized). .env APP_URL=http://curriculum.test SANCTUM_STATEFUL_DOMAINS=curriculim.test,localhost,127.0.0.1 SESSION_DOMAIN=.curriculim.test SESSION_DRIVER=cookie cors.php ‘paths’ => [‘api/*’, ‘sanctum/csrf-cookie’], ‘allowed_methods’ => [‘*’], ‘allowed_origins’ => [‘*’], ‘allowed_origins_patterns’ => [], ‘allowed_headers’ => [‘*’], ‘exposed_headers’ => [], ‘max_age’ => 0, ‘supports_credentials’ => true, Here’s my ..

Read more

I use Laravel sanctum to make auth With ReactJS in cors.php i set these values ‘paths’ => [‘api/*’, ‘api/csrf-cookie’,’/login’], ‘supports_credentials’ => true, sanctum.php ‘prefix’=>’api’ in React i use axios with credintials axios.get(‘http://www.react.test/api/csrf-cookie’).then(response => { console.log(response); }, { withCredentials: true }); when use Postman i get the Set-Cookie Valuei , but when use browser its not ..

Read more

I am using Laravel sanctum to make auth With ReactJS in cors.php. I have set these values ‘paths’ => [‘api/*’, ‘api/csrf-cookie’,’/login’], ‘supports_credentials’ => true, sanctum.php ‘prefix’=>’api’ in React I use axios with credintials axios.get(‘http://www.react.test/api/csrf-cookie’).then(response => { console.log(response); }, { withCredentials: true }); when using Postman, I get the Set-Cookie Value , but when I try ..

Read more

i have this function for get orders for only authenticated user: function show($uid) { try { $user = User::findOrFail($uid); $orders = $user->orders; return $orders; }catch (Exception $e) { return response()->json([‘messsage’ => "cannot show order for this user"]); } } it is a end point for API in this route: Route::group([‘middleware’ => [‘auth:sanctum’]], function () { ..

Read more

I’m using laravel-websockets under Jetstream with laravel-modules on localhost. Public channels work well but when I switch to private channels I get the following error: POST http://127.0.0.1:8000/broadcasting/auth [HTTP/1.1 500 Internal Server Error 104ms] Here is how my code looks like, any help would be much appreciated and thank you in advance! resources/js/bootstrap.js import Echo from ..

Read more

I am experiencing a weird problem with Laravel Sanctum. I have configured it as instructed in the documentation and it works without problems. But sometimes it starts to send 419 errors when trying to fetch sanctum-protected routes and only works after clearing browser cookies or resetting app key (php artisan key:generate). It has only happened ..

Read more