hirosystems / explorer

Explore transactions and accounts on the Stacks blockchain. Clone any contract and experiment in your browser with the Explorer sandbox.
https://explorer.hiro.so/
MIT License
136 stars 102 forks source link

Not respecting env var for custom API server #1708

Closed badonyx closed 6 days ago

badonyx commented 3 weeks ago

Explorer no longer respects the environment varaible NEXT_PUBLIC_MAINNET_API_SERVER which is supposed to be used to define a custom API server. Now it always overrides my environment variable and uses the builtin default api.hiro.so.

Rolled back to an older version v1.172.1 and the environment variable is respected again.

BLuEScioN commented 2 weeks ago

I just tested this, and I still the env var respected.

In .env.local I have NEXT_PUBLIC_MAINNET_API_SERVER=https://api.testnet.hiro.so

and I confirmed that the default network is using https://api.testnet.hiro.so

@badonyx Can you provide any further details about what you are doing to use NEXT_PUBLIC_MAINNET_API_SERVER?

badonyx commented 2 weeks ago

It does not work with environment variables from the shell. This always worked before (simplifying a little):

NEXT_PUBLIC_MAINNET_API_SERVER="my://url" pnpm start

The docs do not mention anything about .env.local. I added this file with my configuration to my repository and after rebuilding it works now.

BLuEScioN commented 6 days ago

.env.local is a NextJS feature. It's how NextJS env vars are set and used in the browser. See the docs here - https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables

I also tried setting the env var via the CLI. That worked for me as well.

I ran

NEXT_PUBLIC_MAINNET_API_SERVER="https://api.testnet.hiro.so" pnpm run dev