11import "server-only" ;
22import type { ChainMetadata } from "thirdweb/chains" ;
33import type { ChainService } from "../../app/(app)/(dashboard)/(chain)/types/chain" ;
4- import { API_SERVER_URL , THIRDWEB_API_SECRET } from "../constants/env" ;
4+ import { NEXT_PUBLIC_THIRDWEB_API_HOST } from "../constants/public-envs" ;
5+ import { API_SERVER_SECRET } from "../constants/server-envs" ;
56
67export async function getGasSponsoredChains ( ) {
7- if ( ! THIRDWEB_API_SECRET ) {
8+ if ( ! API_SERVER_SECRET ) {
89 throw new Error ( "API_SERVER_SECRET is not set" ) ;
910 }
10- const res = await fetch ( `${ API_SERVER_URL } /v1/chains/gas-sponsored` , {
11- headers : {
12- "Content-Type" : "application/json" ,
13- "x-service-api-key" : THIRDWEB_API_SECRET ,
11+ const res = await fetch (
12+ `${ NEXT_PUBLIC_THIRDWEB_API_HOST } /v1/chains/gas-sponsored` ,
13+ {
14+ headers : {
15+ "Content-Type" : "application/json" ,
16+ "x-service-api-key" : API_SERVER_SECRET ,
17+ } ,
18+ next : {
19+ revalidate : 15 * 60 , //15 minutes
20+ } ,
1421 } ,
15- next : {
16- revalidate : 15 * 60 , //15 minutes
17- } ,
18- } ) ;
22+ ) ;
1923
2024 if ( ! res . ok ) {
2125 console . error (
@@ -37,15 +41,15 @@ export async function getGasSponsoredChains() {
3741
3842export function getChains ( ) {
3943 return fetch (
40- `${ API_SERVER_URL } /v1/chains` ,
44+ `${ NEXT_PUBLIC_THIRDWEB_API_HOST } /v1/chains` ,
4145 // revalidate every 60 minutes
4246 { next : { revalidate : 60 * 60 } } ,
4347 ) . then ( ( res ) => res . json ( ) ) as Promise < { data : ChainMetadata [ ] } > ;
4448}
4549
4650export function getChainServices ( ) {
4751 return fetch (
48- `${ API_SERVER_URL } /v1/chains/services` ,
52+ `${ NEXT_PUBLIC_THIRDWEB_API_HOST } /v1/chains/services` ,
4953 // revalidate every 60 minutes
5054 { next : { revalidate : 60 * 60 } } ,
5155 ) . then ( ( res ) => res . json ( ) ) as Promise < {
0 commit comments