## Problem Description
I’m experiencing a persistent `MissingBlobsEnvironmentError` in my production Netlify Functions when using Netlify Blobs, despite following the official documentation and implementing the recommended authentication patterns.
## Error Details
ERROR Uncaught Exception
{ "errorType": "MissingBlobsEnvironmentError", "errorMessage": "The environment has not been configured to use Netlify Blobs. To use it manually, supply the following properties when creating a store: siteID, token", "name": "MissingBlobsEnvironmentError", "stack": [ "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", " at getClientOptions (/var/task/netlify/functions/blob-read.js:320:11)", " at getStore (/var/task/netlify/functions/blob-read.js:655:27)", " at Object.<anonymous> (/var/task/netlify/functions/blob-read.js:677:17)", " at Module._compile (node:internal/modules/cjs/loader:1730:14)", " at Object..js (node:internal/modules/cjs/loader:1895:10)", " at Module.load (node:internal/modules/cjs/loader:1465:32)", " at Function._load (node:internal/modules/cjs/loader:1282:12)", " at TracingChannel.traceSync (node:diagnostics_channel:322:14)", " at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)", " at Module.require (node:internal/modules/cjs/loader:1487:12)" ] }
## Current Implementation
I’m using the two-parameter `getStore()` signature as shown in the documentation, with environment-specific credential handling:
import { getStore } from '@netlify/blobs';
// Current implementation following documentation
const fileStore = process.env.NODE_ENV === 'development'
? getStore('link-album-files', {
siteID: process.env.NETLIFY_SITE_ID,
token: process.env.NETLIFY_BLOBS_TOKEN
})
: getStore('link-album-files'); // No options object in production
## Environment Details
- **Package Version:** `@netlify/blobs@10.0.9`
- **Function Type:** Netlify Functions (not Edge Functions)
- **Node.js Runtime:** Default (should be 18.x+)
- **Site ID:** `d06490d5-32fd-4c46-a6d4-75645e45abbb`
- **Local Development:** Works perfectly with explicit credentials
- **Production:** Fails with MissingBlobsEnvironmentError
## Functions Affected
Multiple functions using the same pattern:
- `blob-create.mjs`
- `blob-read.mjs`
- `blob-delete.mjs`
- `blob-move.mjs`
- `get-archive.js`
- `process-link.mjs`
## What I’ve Tried
### 1. Original approach with single object parameter:
// Tried this first
const fileStore = getStore({
name: 'link-album-files'
});
### 2. Conditional credentials with spread operator:
// Also tried this
const fileStore = getStore({
name: 'link-album-files',
...(process.env.NODE_ENV === 'development' ? {
siteID: process.env.NETLIFY_SITE_ID,
token: process.env.NETLIFY_BLOBS_TOKEN
} : {})
});
### 3. Current approach following documentation exactly:
// Current implementation
const fileStore = process.env.NODE_ENV === 'development'
? getStore('link-album-files', {
siteID: process.env.NETLIFY_SITE_ID,
token: process.env.NETLIFY_BLOBS_TOKEN
})
: getStore('link-album-files');
## Documentation References
According to the [Netlify Blobs API documentation]( Netlify Blobs | Netlify Docs ):
> `siteID` (optional): this is set automatically when you use Blobs from Functions, Edge Functions or Build Plugins
> `token` (optional): this is set automatically when you use Blobs from Functions, Edge Functions or Build Plugins
The documentation suggests that when running in Netlify’s environment, these credentials should be automatically provided.
## Questions
1. **Is there a specific environment variable** that Netlify sets to indicate the function is running in production that I should check instead of `NODE_ENV`?
2. **Are there any deployment settings** or site configuration requirements for automatic credential injection to work?
3. **Could this be related to the function bundling process** where environment detection isn’t working as expected?
4. **Is there a way to debug** what environment variables are available in the production function context?
## Additional Context
- The same codebase works perfectly in local development when providing explicit credentials
- This is a hybrid Next.js + Netlify Functions architecture
- All functions are properly deployed and visible in the Netlify dashboard
- The site has Netlify Blobs enabled and other Netlify features work correctly
## Local Development Configuration
For reference, my local `.env.local` contains:
NETLIFY_SITE_ID=d06490d5-32fd-4c46-a6d4-75645e45abbb
NETLIFY_BLOBS_TOKEN=****************************
Any guidance on troubleshooting this issue or understanding why automatic credential injection isn’t working would be greatly appreciated!