Skip to content

401 Unauthorized

You must log in to access this resource. It actually means ‘Unauthenticated’.

Use this when the user tries to access a private endpoint, but they haven’t logged in, or their session token is expired.

import { HttpException, get } from 'shokupan';
export const getProfile = get('/profile', (req) => {
const token = req.headers.authorization;
if (!token) {
throw new HttpException('Missing auth token', 401);
}
// ... fetch profile safely
});