Skip to content

Commit 896429a

Browse files
committed
redirect to lowercase address
it's easier to do your own caching/deduping of requests if you just need to lowercase rather than form a checksum, the API will still return the checksummed address
1 parent 85d09fb commit 896429a

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

next.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ module.exports = {
2929
},
3030
],
3131
headers: async () => [
32+
{
33+
source: "/api/:path*",
34+
headers: [
35+
{ key: "Access-Control-Allow-Credentials", value: "true" },
36+
{ key: "Access-Control-Allow-Origin", value: "*" },
37+
{
38+
key: "Access-Control-Allow-Methods",
39+
value: "GET,OPTIONS,PATCH,DELETE,POST,PUT",
40+
},
41+
],
42+
},
3243
{
3344
has: [
3445
{

src/pages/api/ens/resolve/[address].ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ export default async function handler(
3434
res: NextApiResponse<Data>
3535
) {
3636
const inputAddress = firstParam(req.query.address);
37-
const address = getAddress(inputAddress.toLowerCase());
37+
const lowercaseAddress = inputAddress.toLowerCase();
38+
const address = getAddress(lowercaseAddress);
3839

39-
if (address !== inputAddress) {
40-
return res.redirect(308, resolve(req.url!, address));
40+
if (inputAddress !== lowercaseAddress) {
41+
return res.redirect(307, resolve(req.url!, lowercaseAddress));
4142
}
4243

4344
try {

0 commit comments

Comments
 (0)