DEV Community

Alejandro Reyes
Alejandro Reyes

Posted on

Help please, Problem with Logout

Hi, I'm new using Laravel, I'm developing an application with laravel and react, but when I try to logout a session, console shows this:

Config.jsx:11
POST http://localhost:8000/api/v1/auth/logout 401 (Unauthorized)
:8000/perfiltitular:1 Uncaught (in promise)
AxiosError {message: 'Request failed with status code 401', name: 'AxiosError', code: 'ERR_BAD_REQUEST', config: {…}, request: XMLHttpRequest, …}
code
:
"ERR_BAD_REQUEST"
config
:
{transitional: {…}, adapter: Array(2), transformRequest: Array(1), transformResponse: Array(1), timeout: 0, …}
message
:
"Request failed with status code 401"
name
:
"AxiosError"
request
:
XMLHttpRequest {onreadystatechange: null, readyState: 4, timeout: 0, withCredentials: true, upload: XMLHttpRequestUpload, …}
response
:
{data: {…}, status: 401, statusText: 'Unauthorized', headers: AxiosHeaders, config: {…}, …}
stack
:
"AxiosError: Request failed with status code 401\n at settle (http://[::1]:5173/node_modules/.vite/deps/axios.js?v=7c27b233:1203:12)\n at XMLHttpRequest.onloadend (http://[::1]:5173/node_modules/.vite/deps/axios.js?v=7c27b233:1420:7)\n at Axios.request (http://[::1]:5173/node_modules/.vite/deps/axios.js?v=7c27b233:1780:41)"
[[Prototype]]
:
Error

Could someone help me please? This is my getLogout in Config.jsx
getLogout:()=>axios.post(${base_api_url}/auth/logout)

And here It's my route in api.php
Route::group(['middleware' => 'auth:sanctum'], function () {

    //::auth
    Route::post('/auth/logout', [AuthController::class, 'logout']);
Enter fullscreen mode Exit fullscreen mode

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more