sveltejs / sveltejs/kit

A way to reverse proxying (like Next.js middlewares)

Open
#10,870 3 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the problem

I want to use PostHog, an open source analytics platform.

But request to their server from the browser can be blocked for CORS reasons or blocked by ad-blockers.

A reverse proxy would enable me to send its events through an endpoint in my own website.

https://posthog.com/docs/advanced/proxy/nextjs

I am blocked for this use case because Vercel, the host that I use, do not support middlewares for SvelteKit, see
https://stackoverflow.com/questions/76937328/sveltekit-server-side-rewrites
https://vercel.com/docs/frameworks/sveltekit#server-side-rendering
"While server-side rendered SvelteKit apps do support middleware, SvelteKit does not support URL rewrites from middleware."

https://posthog.com/docs/advanced/proxy/vercel

I do not want to stop using vercel because they are very practical and Sentry, another lib that I use, does not support Cloudflare ATM.

I did not manage to make a tunneling endpoint because the posthog sdk sends streams of data, so If I read the stream and send the request I change the request from a stream to something else and their API endpoint seems to not support it

Describe the proposed solution

A middleware enabling rewrites like the one from Next.js

Alternatives considered

See problem description

Importance

would make my life easier

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No project file or test is named. Start by reviewing SvelteKit's middleware and routing behavior, then compare the linked Next.js, Vercel, and PostHog proxy guidance. Done would require an agreed SvelteKit approach for rewrites or proxying that preserves streamed PostHog requests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.