Describe the bug
We’re trying to upgrade @builder.io/sdk to 2.2.1 from 2.1.1, it fails in build step:
throw new Error("Fetching content failed, expected apiKey to be defined instead got: ".concat(this.apiKey));
The API key is defined as an environment variable and it is passed correctly. We even tried passing an API key directly to the builder.init() function, but it still didn’t work.
Additional context
It also appears that when we attempt to update @builder.io/react to 3.2.0 from 3.1.1, it fails with the same error.
import { Builder } from '@builder.io/react';
Builder.init(process.env.NEXT_PUBLIC_BUILDER_API_KEY!);
if I add
import { builder } from "@builder.io/sdk";
builder.init(process.env.NEXT_PUBLIC_BUILDER_API_KEY!);
I still have the same issue:
Builder integration error: Looks like the Builder SDK has not been initialized properly (your API key has not been set). Make sure you are calling builder.init("«YOUR-API-KEY»"); as early as possible in your application’s code.