Playing
03. Using the same domain

Transcript

00:00
Before we set up Laravel Sanctum, let's look at a crucial step in getting
00:05
authentication working between both of the client and the API. I put this as a separate episode just because it is such a common mistake when you're trying to authenticate that your API and your client don't match. So hopefully this will help.
00:18
Okay, let's go over to our nuxt.config file and let's set up a custom domain for our client. To do this, we're going to use the dev server option, which is an object. And in here, we're going to provide in the host that we want to use. Now we know that our Laravel project is called api.test.
00:37
Again, whatever you have called that, you just want to match this up inside of this host option under dev server. Once you've done that, go ahead and open up your console, stop npm run dev, and then rerun it.
00:49
And you should now be working on an api.test domain. It doesn't matter that the port is different. That's still going to work. But now we have both of these domains matched up from our client and our API.
01:02
So if we just open up our API here by just running api.test, you can see that we've got our Laravel project set up. Okay, both domains are matching. Really straightforward, but a really important step.
17 episodes1 hr 1 min

Overview

Learn how to build a full authentication boilerplate with Nuxt, Sanctum and Fortify.

This course covers everything you need to get started with authentication with Nuxt and Laravel. We’ll start by setting up a Nuxt project and configuring Laravel Sanctum, then add the ability to register, sign in and sign out.

We’ll also cover some TypeScript tips, protecting pages with middleware, and using Vue composables to keep our code tidy.

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

Comments

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