I’m having some problems with blobs, specifically across different environments. Originally I was doing this:
const store = getStore({ name, token, siteID });
But I realized that was always putting the blob in the Netlify UI (prod). Instead, I wanted to work with blobs in dev until I was ready for them to be in prod. The @netlify/blobs npm package says:
To do this, the system that holds the configuration data should set a global variable called
netlifyBlobsContextor an environment variable calledNETLIFY_BLOBS_CONTEXTwith a Base64-encoded, JSON-stringified representation of an object with the following properties:
apiURL(optional) oredgeURL: URL of the Netlify API (for API access) or the edge endpoint (for Edge access)
token: Access token for the corresponding access mode
siteID: ID of the Netlify siteThis data is automatically populated by Netlify in the execution environment for both serverless and edge functions.
With this in place, the
getStoremethod can be called just with the store name. No configuration object is required, since it’ll be read from the environment.
I did those steps and now have a NETLIFY_BLOBS_CONTEXT in my Netlify UI, the site is linked with netlify link. When I run netlify dev –verbose I’m expecting to see the new environment variable in the console. I see all the other ones except this one.
Then when I start using blobs like this:
const store = getStore(name);
I get this:
MissingBlobsEnvironmentError: The environment has not been configured to use Netlify Blobs. To use it manually, supply the following properties when creating a store: siteID, token
Another thing I tried, I moved all of the getStore calls within functions. In the beginning I had the call outside at the top of the file. That was working when I set the token and siteID directly in the getStore function. I figured I’d try moving to see if it did anything. But from what I can see, it looks like the NETLIFY_BLOBS_CONTEXT isn’t being read in netlify dev. What do I need to do?
Edit: I’ll also mention that I did a netlify unlink and the netlify link to see if I needed to relink the site to get the variables to populate. I also tried console logging the process.env.NETLIFY_BLOBS_CONTEXT and it’s undefined.
Edit2: netlify env:list DOES show the variable and so does netlify env –debug. Even after running those commands, it doesn’t work (doesn’t show in netlify dev when running).