Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: solve issues with basic auth username:password in URLs #11179

Merged
merged 8 commits into from
Jan 9, 2024
5 changes: 5 additions & 0 deletions .changeset/long-adults-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: solve issues with basic auth username:password in URLs (#10522)
Rich-Harris marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 9 additions & 2 deletions packages/kit/src/runtime/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,14 @@ export async function start(_app, _target, hydrate) {
);
}

// detect basic auth credentials in the current URL
// https://github.com/sveltejs/kit/pull/11179
// if so, refresh the page without credentials
if (document.URL !== location.href) {
// eslint-disable-next-line no-self-assign
location.href = location.href;
}

app = _app;
routes = parse(_app);
container = __SVELTEKIT_EMBEDDED__ ? _target : document.documentElement;
Expand Down Expand Up @@ -251,8 +259,7 @@ export async function start(_app, _target, hydrate) {
[HISTORY_INDEX]: current_history_index,
[NAVIGATION_INDEX]: current_navigation_index
},
'',
location.href
''
);
}

Expand Down