Comments (4)
What's wrong with cookies ? I can confirm having a "PHP_SESS_ID" cookie that should do the job. Other cookies should be accessible from front side.
I don't really know what was meant by @mentAl-maZe when he was saying that you can share the session state. You might be able to access the session while requesting laravel since your cookies have the "PHP_SESS_ID" available.
Be aware that this is not working if you are working with a PWA.
from nuxt-laravel.
Hi @GautierDele thanks for your answer.
I've been trying to get it working without success...
I try to login with the laravel default auth and then get user status (if the user is logged in or not) but I always get false.
The short version: it seems axios is not sending back the cookies to the back.
The long version:
This is part of my code in the front:
User login:
this.$axios
.$post('/login', { email: '[email protected]', password: '123456' })
.then(console.log)
Check user status:
this.$axios.$post('/loggedin', {}).then(console.log)
nuxt.config.js -> Axios module configuration
...
axios: {
baseURL: "http://localhost:3000", // .custom-domain.test,
credentials: true
},
In the backend:
My routes file (web.php) I use the web guard:
Route::get('/', function () {
return view('welcome');
});
Route::namespace('Api') // <--- Just for better controllers structure /app/Http/Controllers/Api
->group(function () {
Route::post('/signup', 'Auth\RegisterController@register');
Route::post('/login', 'Auth\LoginController@login');
Route::post('/loggedin', 'Auth\LoginController@isLoggedIn');
});
Route::get('/app{path}', '\\' . Pallares\LaravelNuxt\Controllers\NuxtController::class)->name('nuxt')->where('path', '.*');
In my LoginController the only difference with original one is the type of response, I return a json instead of redirect...
...
protected function sendLoginResponse(Request $request)
{
$request->session()->regenerate();
$this->clearLoginAttempts($request);
return $this->authenticated($request, $this->guard()->user());
}
protected function authenticated(Request $request, $user)
{
return response()->json($user);
}
...
In the session.php file I have tried with different settings like:
...
'domain' => '.localhost', //.custom-domain.test,
'http_only' => false | true,
'same_site' => 'lax',
...
etc...
Can you help me with some advices of how you got it work?
Thanks in advance.
from nuxt-laravel.
Hi again, after trying several settings, I got it working with... in the session.php file the "domain" option set to ".my-custom-domain.test" nothing else. I couldn't get it to work only with localhost.
from nuxt-laravel.
@gitllermopalafox
Sry for the long silence, i've been crazy busy and didn't find any time for foss stuff...
@GautierDele Thanks for pitching in ๐
I'm happy your problem is resolved, but could you maybe provide a repo to reproduce your original issue, so i can investigate (once i have time...)
from nuxt-laravel.
Related Issues (14)
- Windows path problem HOT 3
- Axios uses wrong port HOT 19
- Route [nuxt] not defined.
- Rendering meta tags in server side while there is no SSR by now
- Wrong named output file in publicDir HOT 2
- Missing closing bracket in readme
- Added Support to Nuxt Content
- 'render-before' hook deletes entire public directory HOT 3
- Strange behavior with PHP 7.4 HOT 1
- SSR HOT 9
- Add Laravel to Nuxt HOT 2
- Rendering everything to one JSย file HOT 2
- No spa.html HOT 6
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 nuxt-laravel.