Forcing reload on +page.server redirects
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 a /login page which can either show a login form for local accounts, or hit an api server that handes oauth logins, depending on whether oauth was configured and the presence of a ?bypass_oauth=1 parameter.
Basically it goes like this:
- link navigates to
/login - oauth was configured: the
loadfunction of +page.server.ts redirects tohttps://API_DOMAIN/auth/oauth2 - oauth was bypassed or not configured: the /login page is shown as usual
and in my use case, API_DOMAIN is actually the same as the frontend origin.
But when navigating from the client (so, not on the first page load), I get client-side navigated to /auth/oauth2.
Describe the proposed solution
An optional parameter on the Redirect object (not having it on the redirect convenience function is fine to me since the use case is pretty rare) that essentially does what data-sveltekit-reload does
maybe sth like
throw new Redirect(301, "Full URL", { reload: true })
Alternatives considered
Using <a data-svelkit-reload>, but it becomes hard to ensure all links anywhere that point to /login have the correct behavior - it kind of prevents encoding the required redirection logic in the load function itself. Using a <LoginLink> component can work but unfortunately not for everything - in some cases my app calls goto on /login
Using +server.ts - not really an option in my use case since I also have a +page.svelte
Importance
would make my life easier
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
Start by reading the +page.server.ts redirect flow and the Redirect object, then compare it with data-sveltekit-reload, +server.ts, +page.svelte, and goto as described in the issue. The change would be complete when a redirect can request a full reload for client-side navigation without requiring every link to use data-sveltekit-reload.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100