-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Description
Describe the bug
POST request returns pre-rendered page instead of response with the body in newer SvelteKit.In older version this worked just fine.
Reproduction
https://stackblitz.com/edit/sveltejs-kit-template-default-eds4xq?file=src/routes/index.svelte
or just use these two basic files for the project
// src/routes/index.svelte
<script>
async function reqToPost() {
const reqBodyToPost = {
reqBodyToPost: "reqBodyToPost",
};
await fetch("/", {
method: "POST",
body: JSON.stringify(reqBodyToPost),
});
}
</script>
Sending request to POST endpoint in body
<button on:click={reqToPost}>reqToPost</button>
// src/routes/index.js
export async function post() {
return {
status: 200,
body: {
resBodyFromPost: 'resBodyFromPost'
}
};
}Logs
1.0.0-next.192 etwork responds logs:
{"resBodyFromPost":"resBodyFromPost"}1.0.0-next.304 network responds logs:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="description" content="" />
<link rel="icon" href="./favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<div>
// src/routes/index.svelte
Sending request to POST endpoint in body
<button>reqToPost</button>
<script type="module" data-hydrate="1p3q768">
import { start } from "/@fs/home/developer/Documents/EURLEX_PREPARATION/TEST/.svelte-kit/runtime/client/start.js";
start({
target: document.querySelector('[data-hydrate="1p3q768"]').parentNode,
paths: {"base":"","assets":""},
session: {},
route: true,
spa: false,
trailing_slash: "never",
hydrate: {
status: 200,
error: null,
nodes: [
import("/.svelte-kit/runtime/components/layout.svelte"),
import("/src/routes/index.svelte")
],
params: {},
routeId: ""
}
});
</script><script type="application/json" sveltekit:data-type="props">{"resBodyFromPost":"resBodyFromPost"}</script></div>
</body>
</html>System Info
System:
OS: Linux 5.16 Pop!_OS 21.10
CPU: (4) x64 Intel(R) Pentium(R) CPU 3825U @ 1.90GHz
Memory: 315.41 MB / 3.75 GB
Container: Yes
Shell: 5.1.8 - /bin/bash
Binaries:
Node: 16.13.2 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 8.1.2 - /usr/local/bin/npm
npmPackages:
@sveltejs/adapter-auto: next => 1.0.0-next.34
@sveltejs/kit: next => 1.0.0-next.304
svelte: ^3.44.0 => 3.46.6Severity
blocking an upgrade
Additional Information
None
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels