Skip to content

Commit 542e141

Browse files
committed
handle when apikey exists and is not allowed for get-names
1 parent 609b012 commit 542e141

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pages/api/[network]/get-names.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,16 @@ async function handler(req, res) {
5959
offset = 0;
6060
}
6161

62-
6362
const address = req.query.address;
6463
const includeTextRecords = req.query.text_records;
6564
const apiKey = headers.authorization || req.query.api_key;
6665
// Check API key
6766

6867
const allowedApi = await checkApiKey(apiKey, domain);
68+
// if apiKey exists and is not allowed, return 401
69+
if (apiKey && !allowedApi) {
70+
return res.status(401).json({ error: "Unauthorized" });
71+
}
6972

7073
let domainIds = [];
7174
if (domain) {

0 commit comments

Comments
 (0)