Skip to content

fix: move proxy context to URL path#5

Closed
axlistas wants to merge 2 commits into
Enkryptify:mainfrom
axlistas:proxy-integration
Closed

fix: move proxy context to URL path#5
axlistas wants to merge 2 commits into
Enkryptify:mainfrom
axlistas:proxy-integration

Conversation

@axlistas
Copy link
Copy Markdown

@axlistas axlistas commented Apr 30, 2026

Align proxy requests with backend routing by putting
workspace/project/environment in the proxy URL path.

Remove config and is-personal from the wire payload
to match the proxy request schema.

Made-with: Cursor

Summary by CodeRabbit

  • Breaking Changes

    • Removed the optional per-call usePersonal option for proxy requests.
  • Updates

    • Default proxy endpoint now uses the /v1/proxy path.
    • Proxy requests now encode workspace/project/environment in the request URL path instead of in the request body.
  • Documentation

    • README examples updated to match the new proxy request format.

Align proxy requests with backend routing by putting
workspace/project/environment in the proxy URL path.

Remove config and is-personal from the wire payload
to match the proxy request schema.

Made-with: Cursor
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

This PR updates the proxy and interceptor layers: the default proxy endpoint now includes the /v1/proxy path; proxy request context (workspace, project, environment-id) is moved from a nested config object into top-level URL path segments; the is-personal/usePersonal fields and propagation (usePersonalValues) are removed from proxy, interceptor, and related type declarations; proxy request construction now builds a scoped URL and issues fetch to that URL; tests are updated to assert context via request URLs rather than JSON config bodies.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • feat: add interceptor #4 — Refactored interceptor/proxy wiring and introduced wire format and types that this PR modifies (removal of usePersonal/usePersonalValues and wire format changes).
  • feat: added support for proxy #3 — Introduced EnkryptifyProxy and related proxy request option shapes that are being changed (moving context to URL path and removing is-personal).
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: move proxy context to URL path' directly and accurately summarizes the main change across all modified files: relocating workspace/project/environment context from the request body's config object to the URL path structure.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Review rate limit: 3/5 reviews remaining, refill in 16 minutes and 56 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/proxy.test.ts (1)

446-453: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update the default fallback expectation.

When proxy is omitted, the client now defaults to https://proxy.enkryptify.com/v1/proxy, so this assertion should include /v1/proxy or it will fail against src/enkryptify.ts Line 21.

Suggested fix
-        expect(fetchMock.mock.calls[0]?.[0]).toBe("https://proxy.enkryptify.com/ws-1/prj-1/env-1");
+        expect(fetchMock.mock.calls[0]?.[0]).toBe("https://proxy.enkryptify.com/v1/proxy/ws-1/prj-1/env-1");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/proxy.test.ts` around lines 446 - 453, Update the test expectation to
match the new default proxy path: in the "falls back to default POC URL when
nothing else is set" test, change the asserted URL used by Enkryptify when proxy
is omitted (created via makeConfig and exercised by client.proxy.fetch) to
include the new default suffix "/v1/proxy" (i.e. expect
"https://proxy.enkryptify.com/v1/proxy" instead of the old "/ws-1/prj-1/env-1").
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/proxy.ts`:
- Around line 304-306: The helper buildProxyRequestUrl currently appends
workspace/project/environment directly to the normalized base and can drop the
required /v1/proxy segment; update buildProxyRequestUrl to detect if
normalizedBaseUrl already contains the "/v1/proxy" path (allow optional trailing
slash) and, if it does not, insert "/v1/proxy" before appending the encoded
workspace/project/environment; keep using encodeURIComponent for
workspace/project/environment and ensure you trim duplicate slashes when
concatenating.

---

Outside diff comments:
In `@tests/proxy.test.ts`:
- Around line 446-453: Update the test expectation to match the new default
proxy path: in the "falls back to default POC URL when nothing else is set"
test, change the asserted URL used by Enkryptify when proxy is omitted (created
via makeConfig and exercised by client.proxy.fetch) to include the new default
suffix "/v1/proxy" (i.e. expect "https://proxy.enkryptify.com/v1/proxy" instead
of the old "/ws-1/prj-1/env-1").
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f6cce579-fb39-4780-9bb8-4b9c0b1214b0

📥 Commits

Reviewing files that changed from the base of the PR and between acb9e05 and 81a765e.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • README.md
  • src/enkryptify.ts
  • src/interceptor.ts
  • src/proxy.ts
  • src/types.ts
  • tests/interceptor.test.ts
  • tests/proxy.test.ts
💤 Files with no reviewable changes (2)
  • README.md
  • src/types.ts

Comment thread src/proxy.ts
Comment on lines +304 to +306
function buildProxyRequestUrl(baseUrl: string, workspace: string, project: string, environmentId: string): string {
const normalizedBaseUrl = baseUrl.replace(/\/+$/, "");
return `${normalizedBaseUrl}/${encodeURIComponent(workspace)}/${encodeURIComponent(project)}/${encodeURIComponent(environmentId)}`;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Preserve /v1/proxy for user-supplied proxy bases.

DEFAULT_PROXY_URL was updated to include /v1/proxy, but this helper still appends scope directly onto whatever came from config.proxy.url / ENKRYPTIFY_PROXY_URL. A host-only override like "https://proxy.example.com" now becomes https://proxy.example.com/ws/prj/env, which misses the new backend route and breaks existing custom proxy configs.

Possible fix
 function buildProxyRequestUrl(baseUrl: string, workspace: string, project: string, environmentId: string): string {
     const normalizedBaseUrl = baseUrl.replace(/\/+$/, "");
-    return `${normalizedBaseUrl}/${encodeURIComponent(workspace)}/${encodeURIComponent(project)}/${encodeURIComponent(environmentId)}`;
+    const routedBaseUrl = normalizedBaseUrl.endsWith("/v1/proxy")
+        ? normalizedBaseUrl
+        : `${normalizedBaseUrl}/v1/proxy`;
+    return `${routedBaseUrl}/${encodeURIComponent(workspace)}/${encodeURIComponent(project)}/${encodeURIComponent(environmentId)}`;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function buildProxyRequestUrl(baseUrl: string, workspace: string, project: string, environmentId: string): string {
const normalizedBaseUrl = baseUrl.replace(/\/+$/, "");
return `${normalizedBaseUrl}/${encodeURIComponent(workspace)}/${encodeURIComponent(project)}/${encodeURIComponent(environmentId)}`;
function buildProxyRequestUrl(baseUrl: string, workspace: string, project: string, environmentId: string): string {
const normalizedBaseUrl = baseUrl.replace(/\/+$/, "");
const routedBaseUrl = normalizedBaseUrl.endsWith("/v1/proxy")
? normalizedBaseUrl
: `${normalizedBaseUrl}/v1/proxy`;
return `${routedBaseUrl}/${encodeURIComponent(workspace)}/${encodeURIComponent(project)}/${encodeURIComponent(environmentId)}`;
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/proxy.ts` around lines 304 - 306, The helper buildProxyRequestUrl
currently appends workspace/project/environment directly to the normalized base
and can drop the required /v1/proxy segment; update buildProxyRequestUrl to
detect if normalizedBaseUrl already contains the "/v1/proxy" path (allow
optional trailing slash) and, if it does not, insert "/v1/proxy" before
appending the encoded workspace/project/environment; keep using
encodeURIComponent for workspace/project/environment and ensure you trim
duplicate slashes when concatenating.

@axlistas axlistas closed this Apr 30, 2026
@axlistas axlistas deleted the proxy-integration branch April 30, 2026 12:15
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.

1 participant