laravel - User is authenticated when refresh it gets log out? - Stack Overflow

admin2025-04-16  4

I have a Nuxtjs 3 app and a Laravel project in production.

I have my custom Authentication system based on a token from the backend, token": "TOKEN FROM SANCTUM, and linked with the Nuxtjs project. Everything with it works perfectly locally.

When I deploy the Nuxt files on the production server the user is authenticated when refreshed it gets logged out!

So the system design now is:

  • Old Laravel app (example)
  • New Nuxt js project
  • my new API for the Nuxt app (api.example)

How do I deploy?

I run in Nuxt js project npm run generate and take all files that are in .output/public folder to the Laravel project(old one) and put it in public folder with this code in web.php:

Route::get('{any}', [RedirectableLinkController::class, 'show'])->where('any', '.*');

in RedirectableLinkController.php

public function show()
{
  return file_get_contents(public_path('index.html'));
}

I got the User is authenticated when refreshed it gets logged out!

even though there is a token in Cooike I do not know what is the problem ! and whats debug cuz the console does not show any error!:(

转载请注明原文地址:http://anycun.com/QandA/1744796008a87739.html