diff --git a/packages/kit/src/runtime/client/renderer.js b/packages/kit/src/runtime/client/renderer.js index cc8c98212c17..3c0db40a66eb 100644 --- a/packages/kit/src/runtime/client/renderer.js +++ b/packages/kit/src/runtime/client/renderer.js @@ -335,11 +335,10 @@ export class Renderer { }); } else { if (this.router) { - this.router.goto( - new URL(navigation_result.redirect, info.url).href, - { replaceState: true }, - [...chain, info.url.pathname] - ); + this.router.goto(new URL(navigation_result.redirect, info.url).href, {}, [ + ...chain, + info.url.pathname + ]); } else { location.href = new URL(navigation_result.redirect, location.href).href; } diff --git a/packages/kit/test/apps/basics/test/test.js b/packages/kit/test/apps/basics/test/test.js index 5d5d5b9578ce..d1203b732039 100644 --- a/packages/kit/test/apps/basics/test/test.js +++ b/packages/kit/test/apps/basics/test/test.js @@ -1635,7 +1635,7 @@ test.describe.parallel('searchParams', () => { }); test.describe.parallel('Redirects', () => { - test('redirect', async ({ baseURL, page, clicknav }) => { + test('redirect', async ({ baseURL, page, clicknav, back }) => { await page.goto('/redirect'); await clicknav('[href="/redirect/a"]'); @@ -1643,6 +1643,9 @@ test.describe.parallel('Redirects', () => { await page.waitForURL('/redirect/c'); expect(await page.textContent('h1')).toBe('c'); expect(page.url()).toBe(`${baseURL}/redirect/c`); + + await back(); + expect(page.url()).toBe(`${baseURL}/redirect`); }); test('prevents redirect loops', async ({ baseURL, page, javaScriptEnabled }) => {