TypeError due to subdomain logic
Closed this issue · 1 comments
handlebauer commented
When I specify an ARNS_ROOT_HOST
that includes a subdomain and then try to query that node from localhost, I receive:
$ curl localhost:4000/ar-io/healthcheck
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Internal Server Error</pre>
</body>
</html>
I notice in middleware/arns.ts
that if ROOT_HOST_SUBDOMAIN_LENGTH
is greater than req.subdomains.length
(true when requesting from localhost), it is possible for arnsSubdomain
to evaluate to undefined
.
If arnsSubdomain
is undefined
, then
ar-io-node/src/middleware/arns.ts
Line 50 in 924a885
results in
TypeError: Cannot read properties of undefined (reading 'length')
.
Potential fix: return early if req.subdomains.length
is also less than ROOT_HOST_SUBDOMAIN_LENGTH
djwhitt commented
Thanks for the very well written issue! We'll fix this up in the next release.