Update Keystatic client availability check

The check for Keystatic client availability has been updated to also consider the KEYSTATIC_STORAGE_KIND environment variable. The error message has been adapted accordingly to reflect that the client in "Local" mode is only available in a Node.js runtime.
This commit is contained in:
giancarlo
2024-04-19 13:17:33 +08:00
parent 1b0c81a2b9
commit d733c2e653

View File

@@ -34,14 +34,17 @@ async function getWordpressClient() {
}
async function getKeystaticClient() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
if (
process.env.NEXT_RUNTIME === 'nodejs' ||
process.env.KEYSTATIC_STORAGE_KIND !== 'local'
) {
const { KeystaticClient } = await import('../../keystatic/src/client');
return new KeystaticClient();
}
console.error(
`[CMS] Keystatic client is only available in Node.js runtime. Please choose a different CMS client. Returning a mock client instead of throwing an error.`,
`[CMS] Keystatic client using "Local" mode is only available in Node.js runtime. Please choose a different CMS client. Returning a mock client instead of throwing an error.`,
);
return mockCMSClient() as unknown as CmsClient;