An API usually does not maintain a session or send cookies.
Why there gets no cookie set in production mode with laravel?
Hi,
I have developed an API with laravel locally. Now I would like to deploy it on a server for production mode. If I'm testing the login locally everything works fine. But nothing happens after the login trying it on the server. Anyone know why there is that problem?
My environment looks like that:
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=database
SESSION_LIFETIME=120
QUEUE_DRIVER=sync
I think the problem is, that the cookie is not set in the browser. There is a a Response-Cookie but it does not get set. The session is also entered in the databasen the database.
Please help me, I can't resolve that problem by myself.....
Is using the API Authentication instead of normal authentication the right way in this case?
@SebastianS If you’re defining your routes in routes/api.php, yes. Which you should be if you’re using Angular to create a single-page application (SPA).
Your Angular code should be calling API endpoints for its data, authenticating using a token. Read the Passport documentation. It documentations how to access API routes using JavaScript.
Please or to participate in this conversation.