I have tested the AI suggestion for Sanctum : configure the stateful domains dynamically via a middleware.
But I think that Laravel does already the same with Sanctum::currentApplicationUrlWithPort() in the sanctum configuration file.
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
'%s%s',
// 'localhost,localhost:3000,localhost:5173,127.0.0.1,127.0.0.1:5173,127.0.0.1:8000,51.91.67.137:2080,::1',
'',
Sanctum::currentApplicationUrlWithPort()
))),
I think that I have the answer : impossible with Sanctum given that it's necessary to have the back and the from in the same domain.
When reading once again the Sanctum documentation, I think that an API token authentication could work.
https://laravel.com/docs/11.x/sanctum#api-token-authentication
What do you think about it according to my problem ?