Question: A Laravel 8 application with Sanctum.

When I send a request to a defined route using Postman with an access token the response is correct. I'm happy with this.

When I send a request to a defined route using Postman without an access token the response is 401 Access denied. I'm happy with this.

When I send a request to an undefined route using Postman with an access token the response is 401 Unauthenticated. I'm NOT happy with this. I want a more appropriate response, such as 404.

I don't know how to choose what code from my application to include this question. Please ask me for whatever might be useful and I'll add it.

Update:

Thanks to the answer by @MartinZeitler I worked out that the problem is caused by me making Nova accessible at `/` instead of `/nova`.

I did this in `/config/nova.php` by changing

`'path' => '/nova',`
to
`'path' => '/',`.

If I revert this to `'/nova'` then everything works as I expect it to.

But I need Nova at `/`, so what can I do?

Answer: 
It's difficult to answer a routing question without, eg. the output of `php artisan route:list`.  

The 401 likely comes from Sanctum or from missing a catch-all route `Route::any('', [ ... ])`.  

Since Laravel [8.26.0](https://github.com/laravel/framework/releases/tag/v8.26.0), there is a new [`missing()`](https://laravel.com/docs/8.x/routing#customizing-missing-model-behavior) method available.

Beside that, my best bet would be `Illuminate\Foundation\Http\Kernel` ...

```
/**
 * The priority-sorted list of middleware.
 *
 * This forces non-global middleware to always be in the given order.
 *
 * @var array
 */
protected $middlewarePriority = [];

```
The issue in way that token comes from server and stored to local storage. example

```
{success{token:xfdhgkhkhewrh}}

```

Token like

```
'Authorization': 'Bearer' + " " + this.token.success.token

```

from local storage. `**TOKEN UNDEFINED**` was the issue of returning `**401**`.

[For detailed explanation](https://stackoverflow.com/questions/25838183/what-is-the-oauth-2-0-bearer-token-exactly/25843058)