-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…-server-handle-removes-query-parameters Paraglide-SvelteKit Preserve query parameters when redirecting
- Loading branch information
Showing
4 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
"@inlang/paraglide-sveltekit": patch | ||
--- | ||
|
||
fix: Preserve query parameters when redirecting ([inlang-paraglide-js#168](https://github.com/opral/inlang-paraglide-js/issues/168)) | ||
|
||
`i18n.handle` redirects requests if the pathname does not fit the detected language. Previously this would remove any query parameters from the URL. This is no longer the case. | ||
|
||
```ts | ||
redirect(303, "/login?from=/home") // will be redirected to /<lang>/login?from=/home | ||
``` |
9 changes: 9 additions & 0 deletions
9
inlang/source-code/paraglide/paraglide-sveltekit/example/src/routes/redirect/+page.server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { redirect } from "@sveltejs/kit" | ||
|
||
export const prerender = false | ||
|
||
export const actions = { | ||
redirect: async () => { | ||
redirect(303, "/?redirected=true") | ||
}, | ||
} |
3 changes: 3 additions & 0 deletions
3
inlang/source-code/paraglide/paraglide-sveltekit/example/src/routes/redirect/+page.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<form method="post" action="?/redirect"> | ||
<button type="submit">Redirect</button> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters