mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2888] [Feature]: Outbound proxy support for server-side API requests #1470
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1470
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?
Originally created by @qvazzar on GitHub (Jun 27, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2888
Originally assigned to: @SpicyMarinara on GitHub.
What problem does this solve?
I'm running Marinara Engine from a country where a bunch of LLM APIs (OpenAI, Anthropic, etc.) are either throttled or straight up blocked. Spotify and YouTube APIs are also unreliable from here. The usual advice is "just use a VPN", but that proxies my entire machine — my local stuff, my git pushes, my Docker daemon, everything.
Browser proxy extensions don't help either, because the actual API calls are made server-side (safeFetch for LLM, fetchSpotifyApi for Spotify, raw fetch for YouTube data API, bot browser imports). The client is just an SPA talking to the local server. So browser proxy = useless for this.
There's currently no way to route these requests through a proxy without proxying the whole system.
Proposed solution
Add proxy support via environment variables for all outbound HTTP(S) requests on the server. Two tiers, from simplest to most granular:
Tier 1 — Standard env vars (zero config for most users):
HTTP_PROXY,HTTPS_PROXY,NO_PROXY— picked up automatically, just like any other CLI tool respects them.Tier 2 — Per-category overrides (for power users):
LLM_HTTP_PROXY/LLM_HTTPS_PROXY— proxy only LLM provider API calls (OpenAI, Anthropic, Google, OpenRouter, etc.)MUSIC_HTTP_PROXY/MUSIC_HTTPS_PROXY— proxy only Spotify and YouTube API callsIMPORT_HTTP_PROXY/IMPORT_HTTPS_PROXY— proxy only bot browser / external import fetchesWhen a per-category var is set, it wins over the generic
HTTP_PROXY. When none is set, requests go direct (current behavior).Implementation sketch:
undiciis already a dependency (Fastify pulls it in, andsafeFetchalready uses a customundici.Agent). We'd swap inundici.ProxyAgentwhere needed:safeFetch()inpackages/server/src/utils/security.ts— this is the chokepoint for LLM, image gen, TTS, and most other external requests.fetchSpotifyApi()inpackages/server/src/services/spotify/spotify.service.ts— currently uses rawfetch()with no Agent at all.packages/server/src/routes/youtube.routes.ts— same, rawfetch().packages/server/src/routes/bot-browser-*.ts— same pattern.NO_PROXYshould have sensible defaults —localhost,127.0.0.1,*.internal— so local sidecar and embedding services aren't accidentally proxied.Documentation in
.env.exampleanddocs/CONFIGURATION.md.Alternatives considered
FETCH_PROXYvar instead of per-category — simpler, but less flexible. Could still be added as a fallback when per-category vars aren't set.Additional context
No new npm packages needed.
undici.ProxyAgentis already available —safeFetch()insecurity.ts(around line 340) already constructs a customundici.Agentwith DNS validation and timeouts. The integration point is literally "addconnect.proxyto that Agent constructor call and export a helper that reads the env vars".The main engineering question is whether we pipe proxy config through
runtime-config.ts(hot-reloadable with the rest of the env vars) or keep it as straightprocess.envreads. I'd lean towardruntime-config.tsfor consistency, but that's a judgement call for whoever picks this up.Spotify fetch and YouTube fetch don't use
safeFetchat all — they callfetch()directly. So those need separate Agent wiring. Could either refactor them to go throughsafeFetchor give them their own proxy-aware fetch helpers. Either way works.Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@SpicyMarinara commented on GitHub (Jun 28, 2026):
Good idea for an extension, but not something we would consider for the main release.
@qvazzar commented on GitHub (Jun 28, 2026):
Thanks for the response anyway, but according to EXTENSIONS.md extensions are just custom CSS and JS that run in the browser — they can't touch anything on the server side. The requests I need to proxy (LLM API calls, Spotify, YouTube, bot browser imports) are all made by the Node.js server, so a browser extension can't intercept them. That's why this would need to be a main release feature or at minimum a server-side patch.
@SpicyMarinara commented on GitHub (Jun 28, 2026):
Oh, that's an outdated file, I need to update it. Extensions work the same way they do in SillyTavern, they can influence code as well.
@qvazzar commented on GitHub (Jun 28, 2026):
Oh, thanks, looking forward to it.
@SpicyMarinara commented on GitHub (Jun 28, 2026):
Oh, just so you don't misunderstand, I'm not planning on doing it since I'm working on main releases. You can ask someone else or do it yourself.
@qvazzar commented on GitHub (Jun 28, 2026):
What do you mean exactly? Update docs or make an extension? I can make proxy extension for sure, but I need proper docs to do it.
@SpicyMarinara commented on GitHub (Jun 28, 2026):
Updating docs is on us, I meant creating the extension.
@qvazzar commented on GitHub (Jun 30, 2026):
Thanks for the update. I re-read EXTENSIONS.md and went through the codebase after your response, and I think there's a misunderstanding worth clearing up.
SillyTavern extensions do work the same way — they run in the browser context too. Their own docs confirm this:
https://docs.sillytavern.app/for-contributors/writing-extensions/
And SillyTavern has a separate system (Server Plugins) for server-side code — which Marinara doesn't have.
The proxy feature in SillyTavern isn't an extension at all. It's built into the core as
requestProxyin config.yaml:https://docs.sillytavern.app/administration/config-yaml/
So when you say extensions "can influence code as well" — that's true for client-side code, same as Marinara. But proxying LLM/Spotify/YouTube calls requires intercepting the Node.js server's outgoing HTTP requests. A browser extension can't do that in either SillyTavern or Marinara. That's why SillyTavern has
requestProxyas a core server option, not an extension.I checked Marinara's server code — there's no server-side execution for extensions (no
vm, no dynamic imports, no middleware registration), just blob-URL browser execution. So this genuinely can't be done as an extension with the current architecture.@qvazzar commented on GitHub (Jul 8, 2026):
@SpicyMarinara So, is it even possible to see this as a core feature someday? Or could I try to implement it and open a pull request?
@SpicyMarinara commented on GitHub (Jul 8, 2026):
Talked to my team and here are their suggestions!
Alternatives considered:
But what seems best is to simply run Marinara Engine in a Docker and add a proxy or VPN sidecar there. That's basically zero effort and limited to just that scope as well.
@qvazzar commented on GitHub (Jul 8, 2026):
Thanks for taking the time to discuss this with your team. I get why Docker sidecar looks clean, but honestly, for most users it's overkill. Just one env var (FETCH_PROXY or HTTP_PROXY) would work everywhere with no extra installs.
SillyTavern does exactly this and people love it – we can just match that expectation. Per-category vars can stay as primary, global var as fallback, huge QoL win.
I have some questions for you:
· Any real technical blockers? I'm happy to test/PR.
· Could we start with just global proxy, then extend later?
Not trying to push, I just think this would make Marinara way more accessible for casual users, because it already provides almost plug&play experience.