Skip to content

Cloudflare blocking api access #22

Description

@snowcrash999

PubPub.createSDK cannot authenticate when Cloudflare blocks API requests. I noticed other related open issues about SDK api access - will you fix please.

Summary

The documented SDK authentication method does not work when Cloudflare blocks the initial API request.

Reproduction

import { PubPub } from '@pubpub/sdk';

await PubPub.createSDK({
  communityUrl: 'https://example.pubpub.org',
  authToken: process.env.PUBPUB_AUTH_TOKEN!,
});

Actual result

The SDK throws:

Invalid auth token

However, the underlying request to:

GET /api/communities
Authorization: Bearer <token>

returns HTTP 403 with a Cloudflare challenge/block page. The token is therefore not evaluated by the PubPub API.

The same occurs for API requests such as /api/collections and /api/pubs.

Expected result

Authenticated SDK requests should not be blocked by Cloudflare, or the SDK should detect the Cloudflare response and report it clearly instead of reporting an invalid token.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions