xdevguild / nextjs-dapp-template

Open source Next.js app template for the MultiversX blockchain. Including Shadcn UI and Tailwind.
https://multiversx-nextjs-dapp.netlify.app
MIT License
47 stars 16 forks source link

Make the API proxy optional. For example, when someone uses public API, it isn't needed at all #18

Closed juliancwirko closed 1 year ago

juliancwirko commented 1 year ago

First solution:

  1. make the NEXT_PUBLIC_MULTIVERSX_API actual public API endpoint (not proxied)
  2. use a different name for the proxy endpoint, for example, NEXT_PUBLIC_MULTIVERSX_API_PROXY.
  3. allow passing the NEXT_PUBLIC_MULTIVERSX_API_PROXY as optional env var. If not present, then use NEXT_PUBLIC_MULTIVERSX_API as Elrond's public API endpoint (visible for all)

Second solution, probably better:

  1. make the private env var MULTIVERSX_CUSTOM_API optional and check if it exists
  2. keep the public env var NEXT_PUBLIC_MULTIVERSX_API as is, but use it for absolute public API endpoint or for relative proxy API endpoint when MULTIVERSX_CUSTOM_API is configured

Changes will require a new major version and improvements in docs, more info about it (README.md).