Is there anyone familiar with s built with running on one domain (laravelapi.com) and apps connecting to it from another domain (angularapp.com)?
How did you handle the authentication session?
Imagine there is a route in the API like /auth/get-user
, which does this:
AuthController extends Controller
{
//Accessed through /auth/get-user
public function getUser()
{
return Response::json(Auth::user());
}
}
As long as the app and the API are in the same domain, the above code works fine, but when I move them to separate domains, the API just returns a 401 Unauthorized error.
I have set the above error to be returned when ! Auth::check ()
.
So simply, Laravel's auth session doesn't persist when requested through another domain. How would you face this issue?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community