Allow CSR when server endpoints respond with a redirect
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 have server endpoints which always redirect to a page. To be clear, these endpoints redirect to different pages each time, so they can't just be skipped. It doesn't make sense to consider these endpoints as pages because they never display anything, but it does make sense to redirect to them. Currently, if I redirect to a server endpoint, it works fine, but it is done through page requests rather than CSR and the console shows Error: Not found: /server-endpoint.
Describe the proposed solution
SvelteKit should intercept, from the client, redirects made by server endpoints to allow for CSR
Alternatives considered
To avoid getting the error message, I could make the server endpoint respond with the new URL as part of the response body instead of the location header, then write my own redirection logic. However, there are a few problems with this:
- These endpoints won't exclusively be used via my app; I could send links to them elsewhere and I expect people who click the links to be redirected appropriately
- This wouldn't allow for CSR to work
- This involves writing my own logic, which would ideally be handled by SvelteKit
Importance
nice to have
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files or tests. Start by tracing SvelteKit's client-side navigation handling for redirects returned by server endpoints, then verify that a redirect to varying destinations is intercepted during CSR without producing a not-found error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100