From 3edd3b77590b59a252aad91528e2ca21f5a23a4e Mon Sep 17 00:00:00 2001 From: Max Voloshyn Date: Sun, 15 Nov 2026 17:14:53 +0200 Subject: [PATCH] Allow public app setup when Cloudflare Access is disabled --- packages/void/src/cli/platform-app-access.ts | 8 ++++- .../test/unit/platform-app-access.test.ts | 29 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/packages/void/src/cli/platform-app-access.ts b/packages/void/src/cli/platform-app-access.ts index ec0e6ba15..6a6d4ccdf 100644 --- a/packages/void/src/cli/platform-app-access.ts +++ b/packages/void/src/cli/platform-app-access.ts @@ -207,7 +207,13 @@ export async function prepareInstallationAppAccess(input: { try { return (await access.get('organizations')) as Record; } catch (error) { - if (error instanceof PlatformCloudflareApiError && error.status === 404) { + if ( + error instanceof PlatformCloudflareApiError && + (error.status === 404 || + (choice === 'public' && + error.status === 403 && + error.message.startsWith('Cloudflare API error: access.api.error.not_enabled:'))) + ) { return null; } throw error; diff --git a/packages/void/test/unit/platform-app-access.test.ts b/packages/void/test/unit/platform-app-access.test.ts index 962f3ae73..adba6ec93 100644 --- a/packages/void/test/unit/platform-app-access.test.ts +++ b/packages/void/test/unit/platform-app-access.test.ts @@ -233,6 +233,35 @@ describe('guided installation app access', () => { expect(prompts.confirm).not.toHaveBeenCalled(); expect(prompts.password).not.toHaveBeenCalled(); }); + it('allows unmanaged public apps when Cloudflare explicitly reports Access disabled', async () => { + const { input, fetcher } = fixture('public'); + fetcher.mockResolvedValueOnce( + Response.json( + { + success: false, + errors: [{ code: 9999, message: 'access.api.error.not_enabled: Access is not enabled.' }], + }, + { status: 403 }, + ), + ); + expect(JSON.parse(await prepareInstallationAppAccess(input))).toMatchObject({ + mode: 'public', + managed: false, + }); + expect(fetcher).toHaveBeenCalledOnce(); + }); + it('requires an explicit credential when Cloudflare denies the public Access check', async () => { + const { input, fetcher } = fixture('public'); + fetcher.mockResolvedValueOnce( + Response.json( + { success: false, errors: [{ code: 10000, message: 'Authentication error' }] }, + { status: 403 }, + ), + ); + await expect(prepareInstallationAppAccess(input)).rejects.toThrow( + 'VOID_PLATFORM_APP_ACCESS_TOKEN', + ); + }); it('prepares managed public rules under Default-Deny without asking for company policies', async () => { tty(true); const { input } = fixture('public');