Skip to content

Commit 1cab1b2

Browse files
authored
fix: allow redirects to external URLs from within form functions (#14329)
Fixes #14035 No test because weird to test using playwright, a comment should do
1 parent 7d72763 commit 1cab1b2

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

.changeset/quiet-chairs-flow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
fix: allow redirects to external URLs from within form functions

packages/kit/src/runtime/client/client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ function persist_state() {
440440
* @param {number} redirect_count
441441
* @param {{}} [nav_token]
442442
*/
443-
async function _goto(url, options, redirect_count, nav_token) {
443+
export async function _goto(url, options, redirect_count, nav_token) {
444444
/** @type {string[]} */
445445
let query_keys;
446446
const result = await navigate({

packages/kit/src/runtime/client/remote-functions/form.svelte.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
app,
1010
remote_responses,
1111
started,
12-
goto,
12+
_goto,
1313
set_nearest_error_page,
1414
invalidateAll
1515
} from '../client.js';
@@ -102,7 +102,8 @@ export function form(id) {
102102
if (!invalidateAll) {
103103
refresh_queries(refreshes, updates);
104104
}
105-
void goto(form_result.location, { invalidateAll });
105+
// Use internal version to allow redirects to external URLs
106+
void _goto(form_result.location, { invalidateAll }, 0);
106107
} else {
107108
result = undefined;
108109
throw new HttpError(500, form_result.error);

0 commit comments

Comments
 (0)