In this episode, we focus on a super important—but easy to overlook—step when setting up authentication between your Nuxt client and your Laravel API: making sure both your client and API run under the same domain.
We start by jumping into our nuxt.config.js
file to tweak the dev server settings so that our Nuxt app runs on the same domain as our Laravel API (for example, api.test
). This helps prevent authentication headaches down the line, especially when working with cookies and session authentication. The exact setup might be a bit different for you depending on your project, but the key is to have both sides using a matching domain.
Once that's configured, we restart our Nuxt dev server and double check that both projects are running under the same domain (even if ports are different, that's totally fine). It seems like a really basic step, but trust me, it saves a lot of frustration later on! Now we're perfectly set up to move on and actually integrate Sanctum in the next videos.