Skip to content

Conversation

@dev-hari-prasad
Copy link

🔍 Description

This PR improves request handling in the PostgREST client to make it more compatible with custom fetch implementations and fixes Husky hooks to avoid reliance on globally installed binaries.

What changed?

PostgREST client improvements

  • Updated PostgrestBuilder.ts to serialize request headers as a plain object instead of a Headers instance. This avoids compatibility issues with non-standard or custom fetch implementations.
  • Ensured that non-GET/HEAD requests without a body send an empty JSON object ({}) instead of undefined. This fixes edge cases like RPC calls without parameters.
  • Added tests in headers_serialization.test.ts to verify:
    • Headers are passed as plain objects.
    • RPC calls without parameters send {} as the request body.

Husky hook updates

  • Updated .husky/commit-msg and .husky/pre-push to use local binaries (./node_modules/.bin/...) instead of npx.
  • This removes dependency on global installs and reduces environment-related failures.

Why was this change needed?

  • Some environments (notably React Native and custom fetch setups) do not fully support the Headers API, causing requests to fail unexpectedly.
  • PostgREST expects a request body for certain operations (like RPC), and sending no body at all can lead to errors.
  • Using npx inside Husky hooks can break in CI or restricted environments where global binaries are unavailable.

Closes #1562 (if applicable)

📸 Screenshots / Examples

N/A – changes are covered by tests.

🔄 Breaking changes

  • This PR contains no breaking changes

📋 Checklist

  • I have read the Contributing Guidelines
  • My PR title follows the conventional commit format: <type>(<scope>): <description>
  • I have run npx nx format to ensure consistent code formatting
  • I have added tests for new functionality
  • I have updated documentation (not required for this change)

This PR fixes #1562

…ON body

Refactors PostgrestBuilder to serialize headers as a plain object instead of a Headers instance,
ensuring compatibility with environments expecting plain objects.

Also ensures that requests without a body send an empty JSON object for non-GET/HEAD methods.

Adds tests to verify header serialization and correct body handling.
@dev-hari-prasad dev-hari-prasad requested review from a team as code owners January 12, 2026 18:24
@dev-hari-prasad
Copy link
Author

@mandarini @avallete Pls check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant