Skip to content

git handler: allow Git-Protocol in CORS preflight (#371)#372

Merged
melvincarvalho merged 1 commit into
gh-pagesfrom
issue-371-git-protocol-cors
May 8, 2026
Merged

git handler: allow Git-Protocol in CORS preflight (#371)#372
melvincarvalho merged 1 commit into
gh-pagesfrom
issue-371-git-protocol-cors

Conversation

@melvincarvalho
Copy link
Copy Markdown
Contributor

Closes #371.

Summary

  • Adds `Git-Protocol` to `Access-Control-Allow-Headers` at both callsites in `src/handlers/git.js` (the OPTIONS preflight at line 100, and the streaming-response header block at line 220).
  • Unblocks browser git clients (isomorphic-git, etc.) using smart-HTTP protocol v2, which sends `Git-Protocol: version=2` on every request.
  • Frontend at jss.live/git/ can drop its `protocolVersion: 1` workaround once a server with this fix is deployed.

Test plan

  • `npm test` passes
  • `OPTIONS /alice/repo/info/refs` returns `Access-Control-Allow-Headers: Content-Type, Authorization, Git-Protocol`
  • Browser fetch with the `Git-Protocol` header survives preflight

Browser git clients on protocol v2 (e.g. isomorphic-git) send a
Git-Protocol: version=2 request header. Without it in
Access-Control-Allow-Headers, the preflight fails and the smart-HTTP
flow never starts cross-origin.

Two callsites — the OPTIONS preflight handler and the streaming-response
header block both replied with the same hard-coded list. Adding
"Git-Protocol" to both. The frontend's protocolVersion: 1 workaround can
go away once a server with this fix ships.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds CORS support for Git smart-HTTP protocol v2 by allowing the Git-Protocol request header in the git handler responses, enabling browser-based git clients (e.g., isomorphic-git) to work without downgrading to protocol v1.

Changes:

  • Include Git-Protocol in Access-Control-Allow-Headers for the git handler’s OPTIONS preflight response.
  • Include Git-Protocol in Access-Control-Allow-Headers for the streaming response path (raw header block).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@melvincarvalho melvincarvalho merged commit 3db627a into gh-pages May 8, 2026
4 checks passed
@melvincarvalho melvincarvalho deleted the issue-371-git-protocol-cors branch May 8, 2026 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

git handler: allow git-protocol header in CORS preflight responses

2 participants