Playing
03. Running on the same domain

Transcript

00:00
One of the crucial parts about working with Laravel Sanctum is we need
00:03
to be working on the same domain. We can have sub domains, but at the moment within our local development environment, when we go ahead and run npm run dev on our view project, you can see that we by default get a local host here with this port.
00:20
Now for our actual project, this, depending on what you're using to serve this is likely going to be different. I'm using Laravel herd, or if you're using something like Laravel valet, you'll have a dot test domain with the API.
00:34
Now this might seem a little bit odd, but effectively we want to take our client and match up to this domain locally. So this is technically going to be the API domain, but at least we can test it while we are working locally.
00:48
How do we do this? Well, what we're going to do is head over to the editor and under our config file within our client project, we're going to come down here to the bottom of our config here, and we're going to provide the server option.
01:06
Inside of here, what we can do is choose which host we want this to run on. So we want this to run on Laravel Sanctum view API dot test. And although this is our client, we can now access this with that specific port in the browser.
01:22
And even though the port is different, Laravel Sanctum is still going to work. So now that we've done this, we're going to go ahead and just close this off and rerun it just in case. And you can see now it's available on this domain.
01:33
So now at least in a local development environment, the domains are exactly the same. So really, really important step. Otherwise nothing is going to work.
21 episodes1 hr 35 mins

Overview

Learn how to authenticate with a Laravel API from Vue using the Composition API.

We'll start by setting up a fresh Laravel project with Sanctum and Fortify, configure everything step-by-step, and then implement the ability to authenticate from Vue with a simple auth module — thanks to the flexibility of the Composition API.

In the second half of the course, we’ll create our own beautiful starter kit with more features, including registration and middleware to protect routes.

Alex Garrett-Smith
Alex Garrett-Smith
Hey, I'm the founder of Codecourse!

Comments

No comments, yet. Be the first to leave a comment.