Repository: sveltejs/kit (js)

Issue:
Disable router for all links
### Describe the problem

I use sveltekit in a micro-frontend like usage, injecting html and js generated by svelte-kit in another website.
I used `router=false` option to avoid sveltekit to interfere with the router of the receiving site but keep hydration to activate some js interaction.

Since [this PR](https://github.com/sveltejs/kit/pull/6446) was merged I should use this to keep same usage:

> old: router = false / hydrate = true -> new: csr = true + set data-sveltekit-reload if you want native navigations

Unfortunately receiving site links like `<a href="/">Homepage</a>` are still caught by sveltekit router even if I set `data-sveltekit-reload` in `<html>` tag of the receiving site.

### Describe the proposed solution

Bring back another configuration field `router` set to true by default. 
As `csr` and `ssr` fields add a way to configure this new field in `page.js` or `layout.js`

### Alternatives considered

_No response_

### Importance

i cannot use SvelteKit without it

### Additional Information

I don't have all the history of the changes of `router` field, I hope this issue was not already studied. 
It was a very convenient feature for me, I hope I can find a solution.
I can make the PR with proposed solution if needed.

Pull request description:
ignore popstate events from outside the router
fixes #6914

### Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
- [x] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
- [x] This message body should clearly illustrate what problems it solves.
- [x] Ideally, include a test that fails without this PR but passes with it.

### Tests
- [x] Run the tests with `pnpm test` and lint the project with `pnpm lint` and `pnpm check`

### Changesets
- [x] If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running `pnpm changeset` and following the prompts. All changesets should be `patch` until SvelteKit 1.0


Patch:
diff --git a/.changeset/green-timers-develop.md b/.changeset/green-timers-develop.md
new file mode 100644
index 000000000..cc63776d2
--- /dev/null
+++ b/.changeset/green-timers-develop.md
@@ -0,0 +1,5 @@
+---
+'@sveltejs/kit': patch
+---
+
+Prevent Vite from nuking logs on startup
diff --git a/.changeset/new-kangaroos-double.md b/.changeset/new-kangaroos-double.md
new file mode 100644
index 000000000..9f4cce7d3
--- /dev/null
+++ b/.changeset/new-kangaroos-double.md
@@ -0,0 +1,5 @@
+---
+'@sveltejs/kit': patch
+---
+
+Handle hash links with non-ASCII characters when prerendering
diff --git a/.changeset/ninety-colts-protect.md b/.changeset/ninety-colts-protect.md
new file mode 100644
index 000000000..be2234ad6
--- /dev/null
+++ b/.changeset/ninety-colts-protect.md
@@ -0,0 +1,5 @@
+---
+'@sveltejs/kit': patch
+---
+
+Ignore popstate events from outside the router
diff --git a/.changeset/perfect-needles-tap.md b/.changeset/perfect-needles-tap.md
new file mode 100644
index 000000000..be8b72924
--- /dev/null
+++ b/.changeset/perfect-needles-tap.md
@@ -0,0 +1,5 @@
+---
+'@sveltejs/kit': patch
+---
+
+Always set `Accept` and `Accept-Language` headers when making a self-request
diff --git a/.changeset/pre.json b/.changeset/pre.json
index f47dd0e27..217cc23f5 100644
--- a/.changeset/pre.json
+++ b/.changeset/pre.json
@@ -140,6 +140,7 @@
     "calm-spiders-turn",
     "calm-steaks-yell",
     "calm-walls-happen",
+    "calm-ways-jump",
     "chatty-apricots-fly",
     "chatty-ducks-shop",
     "chatty-impalas-smash",
@@ -167,6 +168,7 @@
     "clean-camels-pump",
     "clean-chicken-walk",
     "clean-countries-push",
+    "clean-grapes-think",
     "clean-islands-do",
     "clean-jars-float",
     "clean-schools-doubt",
@@ -307,6 +309,7 @@
     "empty-teachers-cheat",
     "empty-vans-draw",
     "empty-worms-appear",
+    "fair-dolls-press",
     "fair-panthers-notice",
     "fair-pets-bake",
     "fair-rivers-repair",
@@ -406,6 +409,7 @@
     "friendly-dodos-exercise",
     "friendly-eggs-cry",
     "friendly-pears-wash",
+    "friendly-plums-notice",
     "friendly-rivers-argue",
     "friendly-starfishes-yell",
     "funny-ads-move",
@@ -481,6 +485,7 @@
     "green-masks-confess",
     "green-mayflies-shave",
     "green-spoons-count",
+    "green-timers-develop",
     "grumpy-bugs-jog",
     "grumpy-days-compete",
     "grumpy-eyes-destroy",
@@ -678,11 +683,13 @@
     "lovely-seahorses-sell",
     "lovely-sloths-flow",
     "lucky-bottles-kick",
+    "lucky-gifts-jump",
     "lucky-glasses-sell",
     "lucky-guests-act",
     "lucky-moles-count",
     "lucky-phones-march",
     "lucky-plums-listen",
+    "lucky-rocks-marry",
     "many-cups-report",
     "many-eyes-travel",
     "many-forks-sniff",
@@ -857,6 +864,7 @@
     "perfect-ghosts-shake",
     "perfect-kiwis-sneeze",
     "perfect-mayflies-sneeze",
+    "perfect-needles-tap",
     "perfect-rules-burn",
     "perfect-socks-sparkle",
     "pink-ducks-press",
@@ -1467,6 +1475,7 @@
     "wicked-cars-sniff",
     "wicked-humans-taste",
     "wicked-items-repair",
+    "wicked-kiwis-burn",
     "wicked-oranges-share",
     "wicked-plums-count",
     "wicked-rockets-roll",
diff --git a/packages/create-svelte/CHANGELOG.md b/packages/create-svelte/CHANGELOG.md
index 75e83cf8a..79e2ecb53 100644
--- a/packages/create-svelte/CHANGELOG.md
+++ b/packages/create-svelte/CHANGELOG.md
@@ -1,5 +1,11 @@
 # create-svelte
 
+## 2.0.0-next.192
+
+### Patch Changes
+
+- Ignore Vite timestamp files by default in `create-svelte` templates (added to `.gitignore`) ([#7660](https://github.com/sveltejs/kit/pull/7660))
+
 ## 2.0.0-next.191
 
 ### Patch Changes
diff --git a/packages/create-svelte/package.json b/packages/create-svelte/package.json
index 02af92a79..d21fce66a 100644
--- a/packages/create-svelte/package.json
+++ b/packages/create-svelte/package.json
@@ -1,6 +1,6 @@
 {
 	"name": "create-svelte",
-	"version": "2.0.0-next.191",
+	"version": "2.0.0-next.192",
 	"repository": {
 		"type": "git",
 		"url": "https://github.com/sveltejs/kit",
diff --git a/packages/kit/CHANGELOG.md b/packages/kit/CHANGELOG.md
index 1142c62e9..8a476a223 100644
--- a/packages/kit/CHANGELOG.md
+++ b/packages/kit/CHANGELOG.md
@@ -1,5 +1,29 @@
 # @sveltejs/kit
 
+## 1.0.0-next.553
+
+### Patch Changes
+
+- Prevent Vite from nuking logs on startup ([#7724](https://github.com/sveltejs/kit/pull/7724))
+
+## 1.0.0-next.552
+
+### Patch Changes
+
+- Don't hardcode version in client bundle ([#7694](https://github.com/sveltejs/kit/pull/7694))
+
+- Allow .d.ts files to have a + prefix ([#7682](https://github.com/sveltejs/kit/pull/7682))
+
+- Expose version from `$app/environment` ([#7689](https://github.com/sveltejs/kit/pull/7689))
+
+- [fix] export HttpError/Redirect interface ([#7701](https://github.com/sveltejs/kit/pull/7701))
+
+- [fix] don't preload fonts by default ([#7704](https://github.com/sveltejs/kit/pull/7704))
+
+- Always set `Accept` and `Accept-Language` headers when making a self-request ([#7722](https://github.com/sveltejs/kit/pull/7722))
+
+- [fix] adjust interfaces to fix type errors ([#7718](https://github.com/sveltejs/kit/pull/7718))
+
 ## 1.0.0-next.551
 
 ### Patch Changes
diff --git a/packages/kit/package.json b/packages/kit/package.json
index 38bd048cf..6f1b5d262 100644
--- a/packages/kit/package.json
+++ b/packages/kit/package.json
@@ -1,6 +1,6 @@
 {
 	"name": "@sveltejs/kit",
-	"version": "1.0.0-next.551",
+	"version": "1.0.0-next.553",
 	"repository": {
 		"type": "git",
 		"url": "https://github.com/sveltejs/kit",
diff --git a/packages/kit/src/core/prerender/fixtures/ids/input.html b/packages/kit/src/core/prerender/fixtures/ids/input.html
index 50b212046..cd6a0b43f 100644
--- a/packages/kit/src/core/prerender/fixtures/ids/input.html
+++ b/packages/kit/src/core/prerender/fixtures/ids/input.html
@@ -1,3 +1,6 @@
 <h2 id="before">before</h2>
 <span data-x='"\\"'>backslash</span>
-<h2 id="after">after</h2>
\ No newline at end of file
+<h2 id="after">after</h2>
+<h2 id="encöded">
+	<a href="#encöded">encöded</a>
+</h2>
diff --git a/packages/kit/src/core/prerender/fixtures/ids/output.json b/packages/kit/src/core/prerender/fixtures/ids/output.json
index ce83978a7..1ad4d8f3f 100644
--- a/packages/kit/src/core/prerender/fixtures/ids/output.json
+++ b/packages/kit/src/core/prerender/fixtures/ids/output.json
@@ -1,4 +1,4 @@
 {
-	"hrefs": [],
-	"ids": ["before", "after"]
+	"hrefs": ["#encöded"],
+	"ids": ["before", "after", "encöded"]
 }
diff --git a/packages/kit/src/core/prerender/prerender.js b/packages/kit/src/core/prerender/prerender.js
index aa11d36af..ec6a22418 100644
--- a/packages/kit/src/core/prerender/prerender.js
+++ b/packages/kit/src/core/prerender/prerender.js
@@ -137,7 +137,7 @@ export async function prerender() {
 		config.prerender.handleMissingId,
 		({ path, id, referrers }) => {
 			return (
-				`The following pages contain links to ${path}#${id}, but no element with id="${id}" exists on ${path}:` +
+				`The following pages contain links to ${path}#${id}, but no element with id="${id}" exists on ${path} - see the \`handleMissingId\` option in https://kit.svelte.dev/docs/configuration#prerender for more info:` +
 				referrers.map((l) => `\n  - ${l}`).join('')
 			);
 		}
@@ -262,11 +262,13 @@ export async function prerender() {
 				}
 
 				if (hash) {
-					if (!expected_hashlinks.has(pathname + hash)) {
-						expected_hashlinks.set(pathname + hash, new Set());
+					const key = decodeURI(pathname + hash);
+
+					if (!expected_hashlinks.has(key)) {
+						expected_hashlinks.set(key, new Set());
 					}
 
-					/** @type {Set<string>} */ (expected_hashlinks.get(pathname + hash)).add(decoded);
+					/** @type {Set<string>} */ (expected_hashlinks.get(key)).add(decoded);
 				}
 
 				enqueue(decoded, decodeURI(pathname), pathname);
diff --git a/packages/kit/src/exports/vite/index.js b/packages/kit/src/exports/vite/index.js
index 179924b71..6d8642d0f 100644
--- a/packages/kit/src/exports/vite/index.js
+++ b/packages/kit/src/exports/vite/index.js
@@ -107,9 +107,6 @@ function kit() {
 	/** @type {import('types').BuildData} */
 	let build_data;
 
-	/** @type {string | undefined} */
-	let deferred_warning;
-
 	/** @type {{ public: Record<string, string>; private: Record<string, string> }} */
 	let env;
 
@@ -284,7 +281,9 @@ function kit() {
 				}
 			};
 
-			deferred_warning = warn_overridden_config(config, result);
+			const warning = warn_overridden_config(config, result);
+			if (warning) console.error(warning);
+
 			return result;
 		},
 
@@ -334,6 +333,10 @@ function kit() {
 		 */
 		configResolved(config) {
 			vite_config = config;
+
+			// This is a hack to prevent Vite from nuking useful logs,
+			// pending https://github.com/vitejs/vite/issues/9378
+			config.logger.warn('');
 		},
 
 		/**
@@ -540,14 +543,6 @@ function kit() {
 		 * @see https://vitejs.dev/guide/api-plugin.html#configureserver
 		 */
 		async configureServer(vite) {
-			// This method is called by Vite after clearing the screen.
-			// This patch ensures we can log any important messages afterwards for the user to see.
-			const print_urls = vite.printUrls;
-			vite.printUrls = function () {
-				print_urls.apply(this);
-				if (deferred_warning) console.error('\n' + deferred_warning);
-			};
-
 			return await dev(vite, vite_config, svelte_config);
 		},
 
diff --git a/packages/kit/src/runtime/client/client.js b/packages/kit/src/runtime/client/client.js
index bf2d9f994..c03b18e45 100644
--- a/packages/kit/src/runtime/client/client.js
+++ b/packages/kit/src/runtime/client/client.js
@@ -1458,7 +1458,7 @@ export function create_client({ target, base, trailing_slash }) {
 			});
 
 			addEventListener('popstate', (event) => {
-				if (event.state) {
+				if (event.state?.[INDEX_KEY]) {
 					// if a popstate-driven navigation is cancelled, we need to counteract it
 					// with history.go, which means we end up back here, hence this check
 					if (event.state[INDEX_KEY] === current_history_index) return;
diff --git a/packages/kit/src/runtime/server/fetch.js b/packages/kit/src/runtime/server/fetch.js
index 1b1b60bf6..89f21b5db 100644
--- a/packages/kit/src/runtime/server/fetch.js
+++ b/packages/kit/src/runtime/server/fetch.js
@@ -128,6 +128,17 @@ export function create_fetch({ event, options, state, get_cookie_header }) {
 					throw new Error('Request body must be a string or TypedArray');
 				}
 
+				if (!request.headers.has('accept')) {
+					request.headers.set('accept', '*/*');
+				}
+
+				if (!request.headers.has('accept-language')) {
+					request.headers.set(
+						'accept-language',
+						/** @type {string} */ (event.request.headers.get('accept-language'))
+					);
+				}
+
 				response = await respond(request, options, state);
 
 				const set_cookie = response.headers.get('set-cookie');
diff --git "a/packages/kit/test/prerendering/basics/src/routes/enc\303\266ded-hash-link/+page.svelte" "b/packages/kit/test/prerendering/basics/src/routes/enc\303\266ded-hash-link/+page.svelte"
new file mode 100644
index 000000000..a895dfd0b
--- /dev/null
+++ "b/packages/kit/test/prerendering/basics/src/routes/enc\303\266ded-hash-link/+page.svelte"
@@ -0,0 +1,3 @@
+<h2 id="encöded">
+	<a href="#encöded">encöded</a>
+</h2>


Test patch:
diff --git a/packages/kit/test/apps/basics/src/routes/load/fetch-request-headers.json/+server.js b/packages/kit/test/apps/basics/src/routes/load/fetch-request-headers.json/+server.js
deleted file mode 100644
index d58d91263..000000000
--- a/packages/kit/test/apps/basics/src/routes/load/fetch-request-headers.json/+server.js
+++ /dev/null
@@ -1,13 +0,0 @@
-import { json } from '@sveltejs/kit';
-
-/** @type {import('./$types').RequestHandler} */
-export function GET({ request }) {
-	/** @type {Record<string, string>} */
-	const body = {};
-
-	request.headers.forEach((value, key) => {
-		body[key] = value;
-	});
-
-	return json(body);
-}
diff --git a/packages/kit/test/apps/basics/src/routes/load/fetch-request-headers/+page.js b/packages/kit/test/apps/basics/src/routes/load/fetch-request-headers/+page.js
index 69e85a35b..991d09aef 100644
--- a/packages/kit/test/apps/basics/src/routes/load/fetch-request-headers/+page.js
+++ b/packages/kit/test/apps/basics/src/routes/load/fetch-request-headers/+page.js
@@ -1,6 +1,6 @@
 /** @type {import('@sveltejs/kit').Load} */
 export async function load({ fetch }) {
-	const res = await fetch('/load/fetch-request-headers.json');
+	const res = await fetch('/load/fetch-request-headers/data');
 
 	return {
 		headers: await res.json()
diff --git a/packages/kit/test/apps/basics/src/routes/load/fetch-request-headers/+page.svelte b/packages/kit/test/apps/basics/src/routes/load/fetch-request-headers/+page.svelte
index 27cbe80d0..3987470dd 100644
--- a/packages/kit/test/apps/basics/src/routes/load/fetch-request-headers/+page.svelte
+++ b/packages/kit/test/apps/basics/src/routes/load/fetch-request-headers/+page.svelte
@@ -3,6 +3,8 @@
 	export let data;
 
 	const json = JSON.stringify({
+		accept: data.headers['accept'],
+		'accept-language': data.headers['accept-language'],
 		connection: data.headers['connection'],
 		'sec-fetch-dest': data.headers['sec-fetch-dest'],
 		'sec-fetch-mode': data.headers['sec-fetch-mode'],
diff --git a/packages/kit/test/apps/basics/src/routes/load/fetch-request-headers/data/+server.js b/packages/kit/test/apps/basics/src/routes/load/fetch-request-headers/data/+server.js
new file mode 100644
index 000000000..4d9966804
--- /dev/null
+++ b/packages/kit/test/apps/basics/src/routes/load/fetch-request-headers/data/+server.js
@@ -0,0 +1,6 @@
+import { json } from '@sveltejs/kit';
+
+/** @type {import('./$types').RequestHandler} */
+export function GET({ request }) {
+	return json(Object.fromEntries(request.headers));
+}
diff --git a/packages/kit/test/apps/basics/src/routes/routing/external-popstate/+page.svelte b/packages/kit/test/apps/basics/src/routes/routing/external-popstate/+page.svelte
new file mode 100644
index 000000000..964f3d7d1
--- /dev/null
+++ b/packages/kit/test/apps/basics/src/routes/routing/external-popstate/+page.svelte
@@ -0,0 +1,7 @@
+<h1>hello</h1>
+
+<button
+	on:click={() => {
+		history.pushState({}, '', '/routing/external-popstate/does-not-exist');
+	}}>go to /routing/external-popstate/does-not-exist</button
+>
diff --git a/packages/kit/test/apps/basics/test/client.test.js b/packages/kit/test/apps/basics/test/client.test.js
index 9c11830d0..7531f81ff 100644
--- a/packages/kit/test/apps/basics/test/client.test.js
+++ b/packages/kit/test/apps/basics/test/client.test.js
@@ -791,6 +791,20 @@ test.describe('Routing', () => {
 			await close();
 		}
 	});
+
+	test('ignores popstate events from outside the router', async ({ page }) => {
+		await page.goto('/routing/external-popstate');
+		expect(await page.textContent('h1')).toBe('hello');
+
+		await page.click('button');
+		expect(await page.textContent('h1')).toBe('hello');
+
+		await page.goBack();
+		expect(await page.textContent('h1')).toBe('hello');
+
+		await page.goForward();
+		expect(await page.textContent('h1')).toBe('hello');
+	});
 });
 
 test.describe('Shadow DOM', () => {
diff --git a/packages/kit/test/apps/basics/test/test.js b/packages/kit/test/apps/basics/test/test.js
index 2ee921709..be47fcb68 100644
--- a/packages/kit/test/apps/basics/test/test.js
+++ b/packages/kit/test/apps/basics/test/test.js
@@ -817,6 +817,8 @@ test.describe('Load', () => {
 
 		if (javaScriptEnabled) {
 			expect(headers).toEqual({
+				accept: '*/*',
+				'accept-language': 'en-US',
 				// the referer will be the previous page in the client-side
 				// navigation case
 				referer: `${baseURL}/load`,
@@ -827,7 +829,10 @@ test.describe('Load', () => {
 				connection: 'keep-alive'
 			});
 		} else {
-			expect(headers).toEqual({});
+			expect(headers).toEqual({
+				accept: '*/*',
+				'accept-language': 'en-US'
+			});
 		}
 	});