sveltejs / sveltejs/kit

Allow redirects from handleError server hook

Open
#13,625 1 comment 0 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

Currently, I'm throwing an "unexpected" error so that I can get access to the event object to add information, returning an error object with a flag, and then redirecting when it gets back to the layout if it contains the flag. The error is an auth error in a generic request wrapper so it gets used in lots of places that would make passing in event or page information difficult.

Describe the proposed solution

Allow for redirecting from the handleError server hook so that there doesn't need to be an extra return trip.

Alternatives considered

Adding a hook for expected errors. This way I could throw the redirect whenever but still have access to a hook point where I could transform the redirect (e.g. adding in return info).

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

Start by tracing the server-side handleError hook and the existing redirect handling path. Determine how a redirect could be initiated from that hook without the extra return trip, and verify that the completed behavior supports the authentication-error scenario described in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.