Skip to content

Commit

Permalink
chore: sync staging → main
Browse files Browse the repository at this point in the history
Signed-off-by: Griko Nibras <[email protected]>
  • Loading branch information
grikomsn committed Dec 21, 2023
2 parents de9d252 + 60efaee commit 454226e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 38 deletions.
56 changes: 23 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"@radix-ui/react-toast": "^1.1.5",
"@radix-ui/react-toggle-group": "^1.0.4",
"@radix-ui/react-tooltip": "^1.0.7",
"@react-stately/table": "^3.11.4",
"@sentry/nextjs": "^7.90.0",
"@skip-router/core": "^1.1.2",
"@tanstack/react-query": "^5.14.2",
Expand Down
4 changes: 4 additions & 0 deletions src/constants/rpc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const CHAIN_IDS_L5_NODES = [
"secret-4",
//
];
18 changes: 13 additions & 5 deletions src/pages/api/nodes/[$chainID]/[[...$args]].ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { PageConfig } from "next";
import { NextRequest } from "next/server";

import { CHAIN_IDS_L5_NODES } from "@/constants/rpc";
import { getCorsDomains } from "@/lib/edge-config";
import { getPolkachuAuthHeader } from "@/utils/api";
import { raise } from "@/utils/assert";
Expand Down Expand Up @@ -49,16 +50,23 @@ export default async function handler(req: NextRequest) {
const args = searchParams.getAll("$args");
searchParams.delete("$args");

const rpcURL = `https://${chainID}-skip-rpc.polkachu.com`;
const search = searchParams.toString();
const shouldUseL5 = CHAIN_IDS_L5_NODES.includes(chainID);

const headers = new Headers();
const rpcURL = shouldUseL5
? `https://skip-secretnetwork-rpc.lavenderfive.com`
: `https://${chainID}-skip-rpc.polkachu.com`;

if (!shouldUseL5) {
headers.set("authorization", getPolkachuAuthHeader());
}

const search = searchParams.toString();
const proxyDest = [rpcURL, ...args].join("/") + (search ? `?${search}` : "");

return fetch(proxyDest, {
body: req.body,
headers: {
authorization: getPolkachuAuthHeader(),
},
headers,
method: req.method,
});
}

1 comment on commit 454226e

@vercel
Copy link

@vercel vercel bot commented on 454226e Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.