Skip to content

Commit e01b6cd

Browse files
matt-aitkenericallam
authored andcommitted
No authorization header response is problem+json
1 parent 517b9bd commit e01b6cd

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

apps/webapp/app/services/apiRateLimit.server.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,21 @@ export function authorizationRateLimitMiddleware({
8787
if (log.requests) {
8888
logger.info(`RateLimiter (${keyPrefix}): no key`);
8989
}
90-
return res.status(401).send("Unauthorized");
90+
res.setHeader("Content-Type", "application/problem+json");
91+
return res
92+
.status(401)
93+
.send(
94+
JSON.stringify(
95+
{
96+
title: "Unauthorized",
97+
status: 401,
98+
type: "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401",
99+
detail: "No authorization header provided",
100+
},
101+
null,
102+
2
103+
)
104+
);
91105
}
92106

93107
const hash = createHash("sha256");

0 commit comments

Comments
 (0)