Fix: Correct standalone mode logic and API call

Adjusted the condition for standalone mode to correctly check for
`adminOptions` when `serveStatic` is not enabled, ensuring the warning
message is displayed appropriately.

Updated the `getApi` call to pass optional headers when available,
allowing for authenticated API requests with custom headers.
This commit is contained in:
Cameron Pak
2026-04-06 06:58:43 -05:00
parent 2eba931e39
commit 609eeade23
+2 -2
View File
@@ -25,7 +25,7 @@ export function createBknd<Env>(config: AdapterModeWithOptions<Env>, env?: Env)
async function getApp(): Promise<App> {
if (!appPromise) {
if (mode === "standalone") {
if (!options.serveStatic && !options.adminOptions) {
if (options.adminOptions && !options.serveStatic) {
$console.warn(
"adminOptions provided without serveStatic — admin UI assets may not be served. " +
"See `serveStatic`, `serveStaticViaImport`, or add a `package.json` script that runs `bknd copy-assets --out {relative_static_assets_directory_path}`.",
@@ -46,7 +46,7 @@ export function createBknd<Env>(config: AdapterModeWithOptions<Env>, env?: Env)
await api.verifyAuth();
return api;
}
return app.getApi();
return app.getApi(opts?.headers ? { headers: opts.headers } : undefined);
}
function serve() {