-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed as not planned
Closed as not planned
Copy link
Labels
p1-importantSvelteKit cannot be used by a large number of people, basic functionality is missing, etc.SvelteKit cannot be used by a large number of people, basic functionality is missing, etc.pkg:adapter-node
Milestone
Description
Describe the bug
Given the following scenario:
- Using
@sveltejs/adapter-node(ver^1.0.0-next.61) - Enabled
export const prerender = true;on a page - Have a
POSTendpoint handler on the same path as the pre-rendered page
The artifact produced by the node adapter will always respond with the prerendered page to any requests to the shared path, even if the request uses method POST.
Reproduction
- Clone https://github.com/moatra/svelte-prerender-bug
npm installnpm run dev- Navigate to the
/loginpage with javascript enabled, and use[email protected]andbar. - Note the successful response with content-type
application/json-> The request was served by the endpoint handler.
- Navigate to the
- Kill the dev process
npm run buildnode build- Navigate to the
/loginpage with javascript enabled - Open developer console
- Submit the login page using
[email protected]andbar - Note the "unexpected character at line 1 column 1 of the JSON data" error -> The request was served with the pre-rendered component.
- Navigate to the
Logs
No response
System Info
❯ npx envinfo --system --binaries --browsers --npmPackages "{svelte,@sveltejs/*,vite}"
System:
OS: Linux 5.15 Fedora Linux 35 (Workstation Edition)
CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
Memory: 3.43 GB / 31.08 GB
Container: Yes
Shell: 5.1.8 - /bin/bash
Binaries:
Node: 16.13.0 - /usr/bin/node
npm: 8.1.0 - /usr/bin/npm
Browsers:
Firefox: 95.0.2
npmPackages:
@sveltejs/adapter-auto: next => 1.0.0-next.10
@sveltejs/adapter-node: ^1.0.0-next.61 => 1.0.0-next.61
@sveltejs/kit: next => 1.0.0-next.225
svelte: ^3.44.0 => 3.46.0 Severity
blocking an upgrade
Additional Information
The obvious workaround is to disable pre-rendering, but this meets the current suggested guidelines for when to enable pre-rendering.
When GET-ing the page, every user should receive the same response. It's only once a POST request is made with fallthrough logic that the response should be varied.
Metadata
Metadata
Assignees
Labels
p1-importantSvelteKit cannot be used by a large number of people, basic functionality is missing, etc.SvelteKit cannot be used by a large number of people, basic functionality is missing, etc.pkg:adapter-node