theme-nextjs-bea icon indicating copy to clipboard operation
theme-nextjs-bea copied to clipboard

Environment variables usage

Open e1himself opened this issue 3 years ago • 1 comments

I've noticed that the theme app requires environment variables in order to properly function (at least locally), but the variables themselves are never used within this repo codebase at all. All the usages are actually in the theme-kit package.

I believe this breaks the separation of concerns principle. I cannot modify this theme to do something else with the env variables, or to instantiate the Prezly API client with my own local dev API endpoint.

It would be better if the outsourced theme-kit code was providing entry points expecting the required inputs (like tokens/env variables, or an instantiated API Client instance) and then performed its job.

Of course, this is by all means, not a critical problem. Just something rather good to have.

e1himself avatar Jun 01 '22 15:06 e1himself

I cannot modify this theme to do something else with the env variables, or to instantiate the Prezly API client with my own local dev API endpoint.

Actually, you can do both of these things :)

  • theme-kit-nextjs exports getEnvVariables method, which collects everything from process.env locally (or you can simply use good old process.env).
  • API URL override is not a documented feature, but it is there in the code

I agree that this abstraction might not be the best in terms of intuitiveness, but it does help to reduce the boilerplate. The env variables needed to run the theme locally are documented both in the Theme Kit and the theme repos, so I don't see this as a big problem, at least for now.

riffbyte avatar Jun 01 '22 15:06 riffbyte