Cleanup missing auth header error

This commit is contained in:
Zoe Roux 2025-05-13 22:03:32 +02:00
parent 8592191808
commit c5d05d69aa
No known key found for this signature in database

View File

@ -37,7 +37,7 @@ export const auth = new Elysia({ name: "auth" })
.guard({
headers: t.Object(
{
authorization: t.TemplateLiteral("Bearer ${string}"),
authorization: t.Optional(t.TemplateLiteral("Bearer ${string}")),
},
{ additionalProperties: true },
),
@ -45,9 +45,9 @@ export const auth = new Elysia({ name: "auth" })
.resolve(async ({ headers: { authorization }, status }) => {
const bearer = authorization?.slice(7);
if (!bearer) {
return status(500, {
status: 500,
message: "No jwt, auth server configuration error.",
return status(403, {
status: 403,
message: "No authorization header was found.",
});
}