mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-25 16:55:59 +03:00
[PR #5508] [MERGED] feat(relay): control redirect follow #5244
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#5244
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/hoppscotch/hoppscotch/pull/5508
Author: @CuriousCorrelation
Created: 10/24/2025
Status: ✅ Merged
Merged: 10/27/2025
Merged by: @jamesgeorge007
Base:
next← Head:relay-feat-control-redirect-follow📝 Commits (1)
97003a8feat(relay): control redirect follow📊 Changes
18 files changed (+254 additions, -18 deletions)
View changed files
📝
packages/hoppscotch-agent/src-tauri/Cargo.lock(+3 -3)📝
packages/hoppscotch-common/locales/en.json(+1 -0)📝
packages/hoppscotch-common/src/components/settings/Agent.vue(+23 -0)📝
packages/hoppscotch-common/src/components/settings/Native.vue(+23 -0)📝
packages/hoppscotch-common/src/helpers/functional/domain-settings.ts(+32 -2)📝
packages/hoppscotch-common/src/platform/std/kernel-interceptors/agent/store.ts(+17 -1)📝
packages/hoppscotch-common/src/platform/std/kernel-interceptors/native/store.ts(+17 -1)📝
packages/hoppscotch-desktop/plugin-workspace/relay/src/interop.rs(+17 -0)📝
packages/hoppscotch-desktop/plugin-workspace/relay/src/request.rs(+82 -0)📝
packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-relay/Cargo.lock(+1 -1)📝
packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-relay/dist-js/index.d.ts(+12 -0)📝
packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-relay/dist-js/index.d.ts.map(+1 -1)📝
packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-relay/guest-js/index.ts(+15 -0)📝
packages/hoppscotch-desktop/src-tauri/Cargo.lock(+2 -2)📝
packages/hoppscotch-desktop/src-tauri/Cargo.toml(+1 -1)📝
packages/hoppscotch-kernel/package.json(+1 -1)📝
packages/hoppscotch-kernel/src/relay/impl/desktop/v/1.ts(+1 -0)📝
pnpm-lock.yaml(+5 -5)📄 Description
Add per-domain toggle to disable automatic HTTP redirect following in
the Native and Agent interceptors. When disabled, requests return the
redirect response (status code, headers, body) without following the
Location header.
Closes FE-1035
Closes #2095
Previously HTTP redirects were always followed (on browser, can't do
much about that, see
https://fetch.spec.whatwg.org/#atomic-http-redirect-handling) without
option to inspect the redirect response itself. This prevented
developers from accessing redirect metadata needed when testing OAuth
flows (PKCE where intermediate responses contain authorization tokens),
authentication endpoints that return codes in Location headers with 302
status, and debugging API redirect chains. But on the desktop app,
redirects were just never followed, creating the opposite effect.
The browser's fetch API applies atomic HTTP redirect handling per spec,
making it impossible to intercept redirects and inspect their responses.
The Native and Agent interceptors use curl and native HTTP clients
respectively, both supporting redirect control, making this feature
viable for these specific interceptors. (Proxyscotch tbd).
Changes
Frontend Settings Pages
Added toggle in
Native.vueandAgent.vueinterceptor settingspositioned after "Verify Peer" in the security section, labeled
"Follow Redirects" with default enabled to maintain backward
compatibility.
Defaulting to
truefor consistency with the browser and overallHoppscotch ecosystem mainly. If one platform prescribes, it's better to
stick with it.
Domain Settings Structure
Extended
InputDomainSettingtype with newoptionsnamespace storingrequest-level behavior configuration:
This was already present in
hoppscotch-kernelfor just suchuse-cases.
The
optionsfield defaults to{ followRedirects: true }in defaultdomain config for both interceptors, preserving existing behavior as
mentioned above.
Settings Conversion
Updated
domain-settings.tsconverter to map domain settingsoptionsto
RelayRequest.meta.options. The converter uses Either/Option typesfor safe(r) composition:
Stores merge domain-specific overrides with global defaults, applying
domain settings when resolving merged configuration via
getMergedSettings(host).Rust Backend Types
Added request metadata structs in relay interop:
Request struct includes
meta: Option<RequestMeta>field passed fromfrontend through the relay plugin.
Again this was already present in
hoppscotch-kernelfor just suchuse-cases.
Curl Configuration
Request processing applies settings to curl handle. When
follow_redirectsis false, curl returns the initial redirect response:
Error handling logs at appropriate levels (debug for success, error for
failures) with contextual messages. Although I don't imagine this
happening.
Behavior
With followRedirects: true (default)
Request to
https://httpbin.org/redirect/3follows all redirects andreturns 200 from final destination with complete response body.
NOTE: Check
Networktab from the dev tools.With followRedirects: false
Same request returns 302 with redirect HTML body and Location header
intact, allowing inspection of redirect details.
NOTE: Check
Networktab from the dev tools.Compatibility
API Surface
No changes to request/response contracts. The
metafield is optionaland backend applies defaults when not provided.
Browser Interceptors
Extension and Proxy interceptor show no redirect control in settings
since browser APIs prevent redirect interception. These interceptors
continue using browser defaults (always follow redirects).
Bundle Format
No changes. This is purely request-time behavior configuration.
Testing
Verify with https://httpbin.org/redirect/3:
NOTE: Check
Networktab from the dev tools.With
followRedirects: true(default):/getendpointWith
followRedirects: false:Backward Compatibility
Default behavior maintains automatic redirect following. Existing users
experience no change unless they explicitly disable redirects for a
domain. All domain settings migration preserves existing configuration
without loss. For example it would be prevented on desktop, but "default"
is follow always, hence consistency across platforms.
This is purely additive functionality that does not modify existing
request/response handling as per the web app.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.