Preconfigure client #483
-
|
👋👋👋 How can I globally configure all requests via If I specify this in the settings now, it doesn't work, my prefix is removed: sanctum: {
baseUrl: process.env.NUXT_PUBLIC_SANCTUM_BASE_URL + '/api/v1'
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
|
Hey @projct1, this is the right way of doing this, module will use Here is the example: export default defineNuxtConfig({
modules: [
// other modules
'nuxt-auth-sanctum'
],
sanctum: {
baseUrl: 'http://localhost:80/api/v1',
}
})Then, to load identity the module will call Please make sure you are using proper configuration and you have no overrides via environment variables. |
Beta Was this translation helpful? Give feedback.
-
|
By the way, when i using Route::prefix('v1')->group(function () {
Route::get('user', function (Request $request) {
return $request->user() ? new UserResource($request->user()->load('roles', 'permissions')) : null;
});
})->middleware('auth:sanctum');And in sanctum: {
baseUrl: process.env.NUXT_PUBLIC_SANCTUM_BASE_URL
} |
Beta Was this translation helpful? Give feedback.

Hey @projct1, this is the right way of doing this, module will use
baseUrlas a prefix for all requests including sanctum token fetching (make sure to change the route on Laravel's side to support prefix).Here is the example:
Then, to load identity the module will call
http://localhost:80/api/v1/api/user(if default config is used) andhttp://localhost:80/api/v1/sanctum/csrf-tokento fetch a cookie content.Please make sure you are using proper configuration and you have no overrides via environment variables.